.NetCore 简单的使用中间件

//定义中间件

app.Use(next =>
{
       return new RequestDelegate(async c =>
      {
    await c.Response.WriteAsync("start-88888888888");
    await next.Invoke(c);
    await c.Response.WriteAsync("end-88888888888");
      });
});

中间件我们通常是把上面的方法给提出来并放在一个class类里面,并进一步使用扩展方法中 IApplicationBuilder:

猜你喜欢

转载自www.cnblogs.com/Fengge518/p/12242435.html