zoukankan      html  css  js  c++  java
  • 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........");
                });
            }
  • 相关阅读:
    每日总结4.25
    每日总结4.24
    每日总结4.23
    每日博客4.22
    每日博客4.21
    每日博客4.20
    每日总结4.19
    每日总结4.16
    每日总结4.15
    每日总结4.14
  • 原文地址:https://www.cnblogs.com/qinzb/p/9339191.html
Copyright © 2011-2022 走看看