27-Middleware管道介绍
1-Middleware管道介绍,. 如果匹配上/task,则界面只会显示i am task.
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.Map("/task",taskApp=>{ //路由匹配 taskApp.Run(async (context)=>{ await context.Response.WriteAsync("i am task"); }); }); app.Use(async (context,next) => { await context.Response.WriteAsync("start1....."); await next.Invoke(); }); app.Use( next => { return (context)=>{ context.Response.WriteAsync("middle...."); return next(context); //如果不调用next方法,下面的end不会显示 }; }); app.Run(async (context) => { await context.Response.WriteAsync("end........"); }); }