码迷,mamicode.com
首页 > 其他好文 > 详细

27-Middleware管道介绍

时间:2018-07-20 01:15:44      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:configure   war   nbu   response   tin   end   developer   build   ext   

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........");
            });
        }

 

27-Middleware管道介绍

标签:configure   war   nbu   response   tin   end   developer   build   ext   

原文地址:https://www.cnblogs.com/qinzb/p/9339191.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!