UseExtensions.Use 方法

定义

重载

Use(IApplicationBuilder, Func<HttpContext,RequestDelegate,Task>)

将内联定义的中间件委托添加到应用程序的请求管道。 如果不调用下一个函数,请改用 Run(IApplicationBuilder, RequestDelegate)

Use(IApplicationBuilder, Func<HttpContext,Func<Task>,Task>)

将内联定义的中间件委托添加到应用程序的请求管道。 如果不调用下一个函数,请改用 Run(IApplicationBuilder, RequestDelegate)

为了获得更好的性能,首选使用 Use(IApplicationBuilder, Func<HttpContext,RequestDelegate,Task>) ,如下所示:

app.Use((context, next) =>
{
    return next(context);
});

Use(IApplicationBuilder, Func<HttpContext,RequestDelegate,Task>)

Source:
UseExtensions.cs

将内联定义的中间件委托添加到应用程序的请求管道。 如果不调用下一个函数,请改用 Run(IApplicationBuilder, RequestDelegate)

public static Microsoft.AspNetCore.Builder.IApplicationBuilder Use (this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Func<Microsoft.AspNetCore.Http.HttpContext,Microsoft.AspNetCore.Http.RequestDelegate,System.Threading.Tasks.Task> middleware);
static member Use : Microsoft.AspNetCore.Builder.IApplicationBuilder * Func<Microsoft.AspNetCore.Http.HttpContext, Microsoft.AspNetCore.Http.RequestDelegate, System.Threading.Tasks.Task> -> Microsoft.AspNetCore.Builder.IApplicationBuilder
<Extension()>
Public Function Use (app As IApplicationBuilder, middleware As Func(Of HttpContext, RequestDelegate, Task)) As IApplicationBuilder

参数

middleware
Func<HttpContext,RequestDelegate,Task>

处理请求并调用给定的下一个函数的函数。

返回

IApplicationBuilder 实例。

适用于

Use(IApplicationBuilder, Func<HttpContext,Func<Task>,Task>)

Source:
UseExtensions.cs
Source:
UseExtensions.cs
Source:
UseExtensions.cs

将内联定义的中间件委托添加到应用程序的请求管道。 如果不调用下一个函数,请改用 Run(IApplicationBuilder, RequestDelegate)

为了获得更好的性能,首选使用 Use(IApplicationBuilder, Func<HttpContext,RequestDelegate,Task>) ,如下所示:

app.Use((context, next) =>
{
    return next(context);
});

public:
[System::Runtime::CompilerServices::Extension]
 static Microsoft::AspNetCore::Builder::IApplicationBuilder ^ Use(Microsoft::AspNetCore::Builder::IApplicationBuilder ^ app, Func<Microsoft::AspNetCore::Http::HttpContext ^, Func<System::Threading::Tasks::Task ^> ^, System::Threading::Tasks::Task ^> ^ middleware);
public static Microsoft.AspNetCore.Builder.IApplicationBuilder Use (this Microsoft.AspNetCore.Builder.IApplicationBuilder app, Func<Microsoft.AspNetCore.Http.HttpContext,Func<System.Threading.Tasks.Task>,System.Threading.Tasks.Task> middleware);
static member Use : Microsoft.AspNetCore.Builder.IApplicationBuilder * Func<Microsoft.AspNetCore.Http.HttpContext, Func<System.Threading.Tasks.Task>, System.Threading.Tasks.Task> -> Microsoft.AspNetCore.Builder.IApplicationBuilder
<Extension()>
Public Function Use (app As IApplicationBuilder, middleware As Func(Of HttpContext, Func(Of Task), Task)) As IApplicationBuilder

参数

middleware
Func<HttpContext,Func<Task>,Task>

处理请求并调用给定的下一个函数的函数。

返回

IApplicationBuilder 实例。

适用于