UseExtensions.Use 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
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>) 以提升效能,如下所示:
|
Use(IApplicationBuilder, Func<HttpContext,RequestDelegate,Task>)
將內嵌定義的中介軟體委派新增至應用程式的要求管線。 如果您未呼叫下一個函式,請改用 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
參數
IApplicationBuilder 執行個體。
- middleware
- Func<HttpContext,RequestDelegate,Task>
處理要求的函式,並呼叫指定的下一個函式。
傳回
IApplicationBuilder 執行個體。
適用於
Use(IApplicationBuilder, Func<HttpContext,Func<Task>,Task>)
將內嵌定義的中介軟體委派新增至應用程式的要求管線。 如果您未呼叫下一個函式,請改用 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
參數
IApplicationBuilder 執行個體。
- middleware
- Func<HttpContext,Func<Task>,Task>
處理要求的函式,並呼叫指定的下一個函式。
傳回
IApplicationBuilder 執行個體。