WebApplication 類別

定義

用來設定 HTTP 管線和路由的 Web 應用程式。

public sealed class WebApplication : IAsyncDisposable, IDisposable, Microsoft.AspNetCore.Builder.IApplicationBuilder, Microsoft.AspNetCore.Routing.IEndpointRouteBuilder, Microsoft.Extensions.Hosting.IHost
type WebApplication = class
    interface IHost
    interface IDisposable
    interface IApplicationBuilder
    interface IEndpointRouteBuilder
    interface IAsyncDisposable
Public NotInheritable Class WebApplication
Implements IApplicationBuilder, IAsyncDisposable, IDisposable, IEndpointRouteBuilder, IHost
繼承
WebApplication
實作

屬性

名稱 Description
Configuration

應用程式已設定 IConfiguration好。

Environment

應用程式已設定 IWebHostEnvironment好。

Lifetime

可讓取用者收到應用程式存留期事件的通知。

Logger

應用程式的預設記錄器。

Services

應用程式的已設定服務。

Urls

HTTP 伺服器所系結的 URL 清單。

方法

名稱 Description
Create(String[])

初始化一個已預設的類別實例 WebApplication

CreateBuilder()

初始化一個已預設的類別實例 WebApplicationBuilder

CreateBuilder(String[])

初始化一個已預設的類別實例 WebApplicationBuilder

CreateBuilder(WebApplicationOptions)

初始化一個已預設的類別實例 WebApplicationBuilder

CreateEmptyBuilder(WebApplicationOptions)

初始化一個無預設值的新類別實例 WebApplicationBuilder

CreateSlimBuilder()

以最小預設值初始化該 WebApplicationBuilder 類別的新實例。

CreateSlimBuilder(String[])

以最小預設值初始化該 WebApplicationBuilder 類別的新實例。

CreateSlimBuilder(WebApplicationOptions)

以最小預設值初始化該 WebApplicationBuilder 類別的新實例。

DisposeAsync()

處置應用程式。

Run(String)

執行應用程式並封鎖呼叫執行緒直到主機關機。

RunAsync(String)

執行應用程式,並傳回只有在觸發令牌或關閉時才會完成的工作。

StartAsync(CancellationToken)

啟動應用程式。

StopAsync(CancellationToken)

關閉應用程式。

Use(Func<RequestDelegate,RequestDelegate>)

將中間件新增至應用程式要求管線。

明確介面實作

名稱 Description
IApplicationBuilder.ApplicationServices

用來設定 HTTP 管線和路由的 Web 應用程式。

IApplicationBuilder.Build()

用來設定 HTTP 管線和路由的 Web 應用程式。

IApplicationBuilder.New()

用來設定 HTTP 管線和路由的 Web 應用程式。

IApplicationBuilder.Properties

用來設定 HTTP 管線和路由的 Web 應用程式。

IApplicationBuilder.ServerFeatures

用來設定 HTTP 管線和路由的 Web 應用程式。

IApplicationBuilder.Use(Func<RequestDelegate,RequestDelegate>)

用來設定 HTTP 管線和路由的 Web 應用程式。

IDisposable.Dispose()

處置應用程式。

IEndpointRouteBuilder.CreateApplicationBuilder()

用來設定 HTTP 管線和路由的 Web 應用程式。

IEndpointRouteBuilder.DataSources

用來設定 HTTP 管線和路由的 Web 應用程式。

IEndpointRouteBuilder.ServiceProvider

用來設定 HTTP 管線和路由的 Web 應用程式。

擴充方法

名稱 Description
Map(IApplicationBuilder, PathString, Action<IApplicationBuilder>)

根據指定要求路徑的相符專案,分支要求管線。 如果要求路徑以指定的路徑開頭,則會執行分支。

Map(IApplicationBuilder, PathString, Boolean, Action<IApplicationBuilder>)

根據指定要求路徑的相符專案,分支要求管線。 如果要求路徑以指定的路徑開頭,則會執行分支。

Map(IApplicationBuilder, String, Action<IApplicationBuilder>)

根據指定要求路徑的相符專案,分支要求管線。 如果要求路徑以指定的路徑開頭,則會執行分支。

Map(IEndpointRouteBuilder, RoutePattern, Delegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定模式的 HTTP 請求。

Map(IEndpointRouteBuilder, RoutePattern, RequestDelegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定模式的 HTTP 請求。

Map(IEndpointRouteBuilder, String, Delegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定模式的 HTTP 請求。

Map(IEndpointRouteBuilder, String, RequestDelegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定模式的 HTTP 請求。

MapAreaControllerRoute(IEndpointRouteBuilder, String, String, String, Object, Object, Object)

在 中加入控制器動作IEndpointRouteBuilder的端點,並指定路由,包含 nameareaNameconstraintspatterndefaultsdataTokens和 。

MapBlazorHub(IEndpointRouteBuilder, Action<HttpConnectionDispatcherOptions>)

將 Blazor Hub 映射到預設路徑。

MapBlazorHub(IEndpointRouteBuilder, String, Action<HttpConnectionDispatcherOptions>)

將 Blazor Hub 映射到路徑 path上。

MapBlazorHub(IEndpointRouteBuilder, String)

將 Blazor Hub 映射到路徑 path上。

MapBlazorHub(IEndpointRouteBuilder)

將 Blazor Hub 映射到預設路徑。

MapConnectionHandler<TConnectionHandler>(IEndpointRouteBuilder, String, Action<HttpConnectionDispatcherOptions>)

將連入要求與所提供連接管線的指定路徑對應。

MapConnectionHandler<TConnectionHandler>(IEndpointRouteBuilder, String)

將連入要求與所提供連接管線的指定路徑對應。

MapConnections(IEndpointRouteBuilder, String, Action<IConnectionBuilder>)

將連入要求與所提供連接管線的指定路徑對應。

MapConnections(IEndpointRouteBuilder, String, HttpConnectionDispatcherOptions, Action<IConnectionBuilder>)

將連入要求與所提供連接管線的指定路徑對應。

MapControllerRoute(IEndpointRouteBuilder, String, String, Object, Object, Object)

在 中IEndpointRouteBuilder加入控制器動作的端點,並指定路由,包含給定name的 、 patterndefaultsconstraintsdataTokens和 。

MapControllers(IEndpointRouteBuilder)

在 中 IEndpointRouteBuilder 加入控制器動作的端點,但未指定任何路由。

MapDefaultControllerRoute(IEndpointRouteBuilder)

新增控制器動作 IEndpointRouteBuilder 端點,並新增預設路由 {controller=Home}/{action=Index}/{id?}

MapDelete(IEndpointRouteBuilder, String, Delegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定模式的 HTTP DELETE 請求。

MapDelete(IEndpointRouteBuilder, String, RequestDelegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定模式的 HTTP DELETE 請求。

MapDynamicControllerRoute<TTransformer>(IEndpointRouteBuilder, String, Object, Int32)

在 中IEndpointRouteBuilder加入一個專門化RouteEndpoint的 ,該動作將嘗試使用路由TTransformer值來選擇控制器動作。

MapDynamicControllerRoute<TTransformer>(IEndpointRouteBuilder, String, Object)

在 中IEndpointRouteBuilder加入一個專門化RouteEndpoint的 ,該動作將嘗試使用路由TTransformer值來選擇控制器動作。

MapDynamicControllerRoute<TTransformer>(IEndpointRouteBuilder, String)

在 中IEndpointRouteBuilder加入一個專門化RouteEndpoint的 ,該動作將嘗試使用路由TTransformer值來選擇控制器動作。

MapDynamicPageRoute<TTransformer>(IEndpointRouteBuilder, String, Object, Int32)

在 中加入一個專門化RouteEndpointIEndpointRouteBuilder,嘗試使用路由TTransformer值來選擇頁面。

MapDynamicPageRoute<TTransformer>(IEndpointRouteBuilder, String, Object)

在 中加入一個專門化RouteEndpointIEndpointRouteBuilder,嘗試使用路由TTransformer值來選擇頁面。

MapDynamicPageRoute<TTransformer>(IEndpointRouteBuilder, String)

在 中加入一個專門化RouteEndpointIEndpointRouteBuilder,嘗試使用路由TTransformer值來選擇頁面。

MapFallback(IEndpointRouteBuilder, Delegate)

在 中IEndpointRouteBuilder加入一個專用RouteEndpoint碼,能將非檔案名稱的請求匹配到最低優先順序。

MapFallback(IEndpointRouteBuilder, RequestDelegate)

在 中IEndpointRouteBuilder加入一個專用RouteEndpoint碼,能將非檔案名稱的請求匹配到最低優先順序。

MapFallback(IEndpointRouteBuilder, String, Delegate)

在 中IEndpointRouteBuilder加入一個專門RouteEndpoint化,以最低優先權匹配所提供的模式。

MapFallback(IEndpointRouteBuilder, String, RequestDelegate)

在 中IEndpointRouteBuilder加入一個專門RouteEndpoint化,以最低優先權匹配所提供的模式。

MapFallbackToAreaController(IEndpointRouteBuilder, String, String, String, String)

在 中IEndpointRouteBuilder加入一個專用RouteEndpoint碼,能將非檔案名稱的請求匹配到最低優先順序。 請求將被路由到一個與 、 controllerarea、 相符action的控制器端點。

MapFallbackToAreaController(IEndpointRouteBuilder, String, String, String)

在 中IEndpointRouteBuilder加入一個專用RouteEndpoint碼,能將非檔案名稱的請求匹配到最低優先順序。 請求將被路由到一個與 、 controllerarea、 相符action的控制器端點。

MapFallbackToAreaPage(IEndpointRouteBuilder, String, String, String)

在 中IEndpointRouteBuilder加入一個專用RouteEndpoint碼,能將非檔案名稱的請求匹配到最低優先順序。 請求會被路由到與 、 area和 相符page的頁面端點。

MapFallbackToAreaPage(IEndpointRouteBuilder, String, String)

在 中IEndpointRouteBuilder加入一個專用RouteEndpoint碼,能將非檔案名稱的請求匹配到最低優先順序。 請求會被路由到與 、 area和 相符page的頁面端點。

MapFallbackToController(IEndpointRouteBuilder, String, String, String)

在 中IEndpointRouteBuilder加入一個專用RouteEndpoint碼,能將非檔案名稱的請求匹配到最低優先順序。 請求會被路由到一個與 、 和 相符actioncontroller的控制器端點。

MapFallbackToController(IEndpointRouteBuilder, String, String)

在 中IEndpointRouteBuilder加入一個專用RouteEndpoint碼,能將非檔案名稱的請求匹配到最低優先順序。 請求會被路由到一個與 、 和 相符actioncontroller的控制器端點。

MapFallbackToFile(IEndpointRouteBuilder, String, StaticFileOptions)

在 中IEndpointRouteBuilder加入一個專用RouteEndpoint,能將非檔名的請求匹配到最低優先順序。 請求會被導向 ,該 A StaticFileMiddleware 嘗試服務由 所 filePath指定的檔案。

MapFallbackToFile(IEndpointRouteBuilder, String, String, StaticFileOptions)

在 中IEndpointRouteBuilder加入一個專用RouteEndpoint,能將非檔名的請求匹配到最低優先順序。 請求會被導向 ,該 A StaticFileMiddleware 嘗試服務由 所 filePath指定的檔案。

MapFallbackToFile(IEndpointRouteBuilder, String, String)

在 中IEndpointRouteBuilder加入一個專用RouteEndpoint,能將非檔名的請求匹配到最低優先順序。 請求會被導向 ,該 A StaticFileMiddleware 嘗試服務由 所 filePath指定的檔案。

MapFallbackToFile(IEndpointRouteBuilder, String)

在 中IEndpointRouteBuilder加入一個專用RouteEndpoint,能將非檔名的請求匹配到最低優先順序。 請求會被導向 ,該 A StaticFileMiddleware 嘗試服務由 所 filePath指定的檔案。

MapFallbackToPage(IEndpointRouteBuilder, String, String)

在 中IEndpointRouteBuilder加入一個專用RouteEndpoint碼,能將非檔案名稱的請求匹配到最低優先順序。 請求會被路由到與 相符 page的頁面端點。

MapFallbackToPage(IEndpointRouteBuilder, String)

在 中IEndpointRouteBuilder加入一個專用RouteEndpoint碼,能將非檔案名稱的請求匹配到最低優先順序。 請求會被路由到與 相符 page的頁面端點。

MapGet(IEndpointRouteBuilder, String, Delegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定模式的 HTTP GET 請求。

MapGet(IEndpointRouteBuilder, String, RequestDelegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定模式的 HTTP GET 請求。

MapGroup(IEndpointRouteBuilder, RoutePattern)

建立 來 RouteGroupBuilder 定義所有以指定 prefix為前綴的端點。

MapGroup(IEndpointRouteBuilder, String)

建立 來 RouteGroupBuilder 定義所有以指定 prefix為前綴的端點。

MapHealthChecks(IEndpointRouteBuilder, String, HealthCheckOptions)

在 中 IEndpointRouteBuilder 加入一個健康檢查端點,並附上指定的範本和選項。

MapHealthChecks(IEndpointRouteBuilder, String)

在 中 IEndpointRouteBuilder 加入一個健康檢查端點,並附上指定的範本。

MapHub<THub>(IEndpointRouteBuilder, String, Action<HttpConnectionDispatcherOptions>)

將輸入請求與指定路徑對應到指定 Hub 型別。

MapHub<THub>(IEndpointRouteBuilder, String)

將輸入請求與指定路徑對應到指定 Hub 型別。

MapIdentityApi<TUser>(IEndpointRouteBuilder)

新增端點,以使用 ASP.NET Core Identity 註冊、登入和註銷。

MapMethods(IEndpointRouteBuilder, String, IEnumerable<String>, Delegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定的 HTTP 方法與模式的 HTTP 請求。

MapMethods(IEndpointRouteBuilder, String, IEnumerable<String>, RequestDelegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定的 HTTP 方法與模式的 HTTP 請求。

MapOpenApi(IEndpointRouteBuilder, String)

將端點註冊至目前的應用程式,以解析與目前應用程式相關聯的 OpenAPI 檔。

MapPatch(IEndpointRouteBuilder, String, Delegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定模式的 HTTP PATCH 請求。

MapPatch(IEndpointRouteBuilder, String, RequestDelegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定模式的 HTTP PATCH 請求。

MapPost(IEndpointRouteBuilder, String, Delegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定模式的 HTTP POST 請求。

MapPost(IEndpointRouteBuilder, String, RequestDelegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定模式的 HTTP POST 請求。

MapPut(IEndpointRouteBuilder, String, Delegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,與指定模式的 HTTP PUT 請求相符。

MapPut(IEndpointRouteBuilder, String, RequestDelegate)

在 中IEndpointRouteBuilder加入 aRouteEndpoint,與指定模式的 HTTP PUT 請求相符。

MapRazorComponents<TRootComponent>(IEndpointRouteBuilder)

將指定 TRootComponent 中定義的頁面元件映射到指定的組裝,並在路由匹配時渲染指定的 TRootComponent 元件。

MapRazorPages(IEndpointRouteBuilder)

新增 Razor Pages 的端點到 IEndpointRouteBuilder.

MapShortCircuit(IEndpointRouteBuilder, Int32, String[])

在 中IEndpointRouteBuilder加入 aRouteEndpoint,以匹配指定的前綴的 HTTP 請求(所有動詞)。

MapStaticAssets(IEndpointRouteBuilder, String)

將建置期間產生的靜態檔案對應為端點。

MapWhen(IApplicationBuilder, Func<HttpContext,Boolean>, Action<IApplicationBuilder>)

根據指定述詞的結果,分支要求管線。

Run(IApplicationBuilder, RequestDelegate)

將終端中間件委派新增至應用程式的要求管線。

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

將內嵌定義的中間件委派新增至應用程式的要求管線。 如果你沒有呼叫下一個函式,就用 Run(IApplicationBuilder, RequestDelegate) inste。

建議使用 Use(IApplicationBuilder, Func<HttpContext,RequestDelegate,Task>) 以取得更好的效能,如下所示:

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

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

將內嵌定義的中間件委派新增至應用程式的要求管線。 如果你沒有呼叫下一個函式,就用 Run(IApplicationBuilder, RequestDelegate) inste。

UseAntiforgery(IApplicationBuilder)

將防偽中間件新增至管線。

UseAuthentication(IApplicationBuilder)

將 加入 AuthenticationMiddleware 指定的 IApplicationBuilder,從而啟用認證功能。

UseAuthorization(IApplicationBuilder)

將 加入 AuthorizationMiddleware 指定的 IApplicationBuilder,使授權功能得以實現。

當授權使用端點路由路由的資源時,這個呼叫必須出現在 和 app.UseRouting()app.UseEndpoints(...) 呼叫之間,中介軟體才能正常運作。

UseBlazorFrameworkFiles(IApplicationBuilder, PathString)

設定應用程式從路徑 pathPrefix提供 Blazor WebAssembly 框架檔案。 此路徑必須對應至參考的 Blazor WebAssembly 應用程式專案。

UseBlazorFrameworkFiles(IApplicationBuilder)

設定應用程式以從根路徑 「/」 提供 Blazor WebAssembly 架構檔案。

UseCertificateForwarding(IApplicationBuilder)

將中間件新增至管線,以尋找要求標頭中的憑證譯碼,並更新 HttpContext.Connection.ClientCertificate。

UseConcurrencyLimiter(IApplicationBuilder)
已淘汰.

新增 以 ConcurrencyLimiterMiddleware 限制同時執行的請求數量。

UseCookiePolicy(IApplicationBuilder, CookiePolicyOptions)

CookiePolicyMiddleware 處理器加入指定的 IApplicationBuilder,使 Cookie 政策功能得以實現。

UseCookiePolicy(IApplicationBuilder)

CookiePolicyMiddleware 處理器加入指定的 IApplicationBuilder,使 Cookie 政策功能得以實現。

UseCors(IApplicationBuilder, Action<CorsPolicyBuilder>)

將 CORS 中間件新增至 Web 應用程式管線,以允許跨網域要求。

UseCors(IApplicationBuilder, String)

將 CORS 中間件新增至 Web 應用程式管線,以允許跨網域要求。

UseCors(IApplicationBuilder)

將 CORS 中間件新增至 Web 應用程式管線,以允許跨網域要求。

UseDatabaseErrorPage(IApplicationBuilder, DatabaseErrorPageOptions)
已淘汰.

從可使用 Entity Framework 移轉解析的管線擷取同步和異步資料庫相關例外狀況。 發生這些例外狀況時,會產生 HTML 回應,其中包含可能解決問題的動作詳細數據。

UseDatabaseErrorPage(IApplicationBuilder)
已淘汰.

從可使用 Entity Framework 移轉解析的管線擷取同步和異步資料庫相關例外狀況。 發生這些例外狀況時,會產生 HTML 回應,其中包含可能解決問題的動作詳細數據。

UseDefaultFiles(IApplicationBuilder, DefaultFilesOptions)

使用指定的選項啟用預設檔案對應

UseDefaultFiles(IApplicationBuilder, String)

啟用指定要求路徑的預設檔案對應

UseDefaultFiles(IApplicationBuilder)

在目前路徑上啟用預設檔案對應

UseDeveloperExceptionPage(IApplicationBuilder, DeveloperExceptionPageOptions)

從管線擷取同步與非同步 Exception 實例,並產生 HTML 錯誤回應。

UseDeveloperExceptionPage(IApplicationBuilder)

從管線擷取同步與非同步 Exception 實例,並產生 HTML 錯誤回應。

UseDirectoryBrowser(IApplicationBuilder, DirectoryBrowserOptions)

使用指定的選項啟用目錄流覽

UseDirectoryBrowser(IApplicationBuilder, String)

啟用指定要求路徑的目錄流覽

UseDirectoryBrowser(IApplicationBuilder)

在目前路徑上啟用目錄流覽

UseEndpoints(IApplicationBuilder, Action<IEndpointRouteBuilder>)

在指定的 IApplicationBuilder 中介軟體中加入 Microsoft.AspNetCore.Routing.EndpointMiddleware 中介軟體,並由配置的 IEndpointRouteBuilder 建置 EndpointDataSource 實例。 Microsoft.AspNetCore.Routing.EndpointMiddleware 會執行與目前請求相關的 Endpoint

UseExceptionHandler(IApplicationBuilder, Action<IApplicationBuilder>)

將中間件新增至管線,以攔截例外狀況、記錄例外狀況,並在替代管線中重新執行要求。 如果回應已啟動,將不會重新執行要求。

UseExceptionHandler(IApplicationBuilder, ExceptionHandlerOptions)

將中間件新增至管線,以攔截例外狀況、記錄例外狀況,並在替代管線中重新執行要求。 如果回應已啟動,將不會重新執行要求。

UseExceptionHandler(IApplicationBuilder, String, Boolean)

將中間件新增至管線,以攔截例外狀況、記錄例外狀況、重設要求路徑,然後重新執行要求。 如果回應已啟動,將不會重新執行要求。

UseExceptionHandler(IApplicationBuilder, String)

將中間件新增至管線,以攔截例外狀況、記錄例外狀況、重設要求路徑,然後重新執行要求。 如果回應已啟動,將不會重新執行要求。

UseExceptionHandler(IApplicationBuilder)

將中間件新增至管線,以攔截例外狀況、記錄例外狀況,並在替代管線中重新執行要求。 如果回應已啟動,將不會重新執行要求。

UseFileServer(IApplicationBuilder, Boolean)

針對目前目錄中的目前要求路徑,啟用 上的所有靜態檔案中間件。

UseFileServer(IApplicationBuilder, FileServerOptions)

使用指定的選項啟用所有靜態檔案中間件

UseFileServer(IApplicationBuilder, String)

針對相同名稱目錄的指定要求路徑啟用所有靜態檔案中間件(目錄流覽除外)

UseFileServer(IApplicationBuilder)

針對目前目錄中的目前要求路徑啟用所有靜態檔案中間件(目錄流覽除外)。

UseForwardedHeaders(IApplicationBuilder, ForwardedHeadersOptions)

將轉送標頭套用至目前要求上的相符欄位。

依照慣例,HTTP Proxy 會從已知 HTTP 標頭中的用戶端轉送資訊。 它 ForwardedHeadersMiddleware 會讀取這些標頭,並在 HttpContext 上填入相關欄位。

UseForwardedHeaders(IApplicationBuilder)

將轉送標頭套用至目前要求上的相符欄位。

依照慣例,HTTP Proxy 會從已知 HTTP 標頭中的用戶端轉送資訊。 它 ForwardedHeadersMiddleware 會讀取這些標頭,並在 HttpContext 上填入相關欄位。

UseHeaderPropagation(IApplicationBuilder)

新增一個中介軟體收集標頭,然後傳播到 HttpClient.

UseHealthChecks(IApplicationBuilder, PathString, HealthCheckOptions)

新增提供健康狀態檢查狀態的中間件。

UseHealthChecks(IApplicationBuilder, PathString, Int32, HealthCheckOptions)

新增提供健康狀態檢查狀態的中間件。

UseHealthChecks(IApplicationBuilder, PathString, Int32)

新增提供健康狀態檢查狀態的中間件。

UseHealthChecks(IApplicationBuilder, PathString, String, HealthCheckOptions)

新增提供健康狀態檢查狀態的中間件。

UseHealthChecks(IApplicationBuilder, PathString, String)

新增提供健康狀態檢查狀態的中間件。

UseHealthChecks(IApplicationBuilder, PathString)

新增提供健康狀態檢查狀態的中間件。

UseHostFiltering(IApplicationBuilder)

新增中間件,以依允許的主機標頭篩選要求。 無效的要求將會因為 400 狀態代碼而遭到拒絕。

UseHsts(IApplicationBuilder)

新增中介軟體以使用 HSTS,並加入 Strict-Transport-Security 標頭。

UseHttpLogging(IApplicationBuilder)

新增可記錄 HTTP 要求和回應的中間件。

UseHttpLoggingMiddleware(IApplicationBuilder)

將收到的 HTTP 請求登錄中介軟體登錄至 IApplicationBuilder

UseHttpMethodOverride(IApplicationBuilder, HttpMethodOverrideOptions)

允許傳入 POST 要求覆寫表單中所指定類型的方法類型。 當用戶端僅限於傳送 GET 或 POST 方法,但想要叫用其他 HTTP 方法時,會使用此中間件。

UseHttpMethodOverride(IApplicationBuilder)

允許傳入 POST 要求覆寫標頭中所指定類型的方法類型。 當用戶端僅限於傳送 GET 或 POST 方法,但想要叫用其他 HTTP 方法時,會使用此中間件。 預設情況下,X-HTTP-Method-Override 請求標頭用來指定正在隧道的 HTTP 方法。

UseHttpsRedirection(IApplicationBuilder)

將 HTTP 要求重新導向至 HTTPS 的中間件。

UseMiddleware(IApplicationBuilder, Type, Object[])

將中間件類型新增至應用程式的要求管線。

UseMiddleware<TMiddleware>(IApplicationBuilder, Object[])

將中間件類型新增至應用程式的要求管線。

UseMigrationsEndPoint(IApplicationBuilder, MigrationsEndPointOptions)

處理執行移轉作業的要求。 中介軟體會監聽對已設定路徑 options的請求。

UseMigrationsEndPoint(IApplicationBuilder)

處理執行移轉作業的要求。 中介軟體會監聽收到的 DefaultPath請求。

UseMvc(IApplicationBuilder, Action<IRouteBuilder>)

將 MVC 加入 IApplicationBuilder 請求執行管線。

UseMvc(IApplicationBuilder)

將 MVC 加入 IApplicationBuilder 請求執行管線。

UseMvcWithDefaultRoute(IApplicationBuilder)

將 MVC 加入 IApplicationBuilder 請求執行管線,預設路由名為 'default',並使用以下範本:'{controller=Home}/{action=Index}/{id?}'。

UseOutputCache(IApplicationBuilder)

新增 Microsoft.AspNetCore.OutputCaching.OutputCacheMiddleware 用於快取 HTTP 回應。

UseOwin(IApplicationBuilder, Action<Action<Func<Func<IDictionary<String,Object>,Task>,Func<IDictionary<String,Object>,Task>>>>)

在指定的 IApplicationBuilder. 中介軟體中新增 OWIN 中介軟體管線。

UseOwin(IApplicationBuilder)

在指定的 IApplicationBuilder. 中加入 OWIN 管線。

UsePathBase(IApplicationBuilder, PathString)

新增中間件,從要求路徑擷取指定的路徑基底,並將它貼到要求路徑基底。

UseRateLimiter(IApplicationBuilder, RateLimiterOptions)

啟用應用程式的速率限制。

UseRateLimiter(IApplicationBuilder)

啟用應用程式的速率限制。

UseRequestCheckpoint(IApplicationBuilder)

註冊中介軟體以進行請求檢查點。

UseRequestCheckpoint(IApplicationBuilder)

向管線註冊要求檢查點相關中間件。

UseRequestDecompression(IApplicationBuilder)

新增用於動態解壓縮 HTTP 要求主體的中間件。

UseRequestLatencyTelemetry(IApplicationBuilder)

新增請求延遲遙測中介軟體以支援 IApplicationBuilder 請求執行管線。

UseRequestLatencyTelemetry(IApplicationBuilder)

新增請求延遲遙測中介軟體以支援 IApplicationBuilder 請求執行管線。

UseRequestLocalization(IApplicationBuilder, Action<RequestLocalizationOptions>)

新增 功能 RequestLocalizationMiddleware ,能根據客戶端提供的資訊自動設定請求的文化資訊。

UseRequestLocalization(IApplicationBuilder, RequestLocalizationOptions)

新增 功能 RequestLocalizationMiddleware ,能根據客戶端提供的資訊自動設定請求的文化資訊。

UseRequestLocalization(IApplicationBuilder, String[])

新增 功能 RequestLocalizationMiddleware ,能根據客戶端提供的資訊自動設定請求的文化資訊。

UseRequestLocalization(IApplicationBuilder)

新增 功能 RequestLocalizationMiddleware ,能根據客戶端提供的資訊自動設定請求的文化資訊。

UseRequestTimeouts(IApplicationBuilder)

啟用應用程式的要求逾時。

預設不會設定逾時。 它們必須在 RequestTimeoutOptionsRequestTimeoutAttribute 點上配置,或使用 WithRequestTimeout 路由擴充功能。

UseResponseCaching(IApplicationBuilder)

新增了 來 ResponseCachingMiddleware 快取 HTTP 回應的功能。

UseResponseCompression(IApplicationBuilder)

新增中間件以動態壓縮 HTTP 回應。

UseRewriter(IApplicationBuilder, RewriteOptions)

檢查指定的 URL 是否符合規則和條件,並在相符專案上修改 HttpContext。

UseRewriter(IApplicationBuilder)

檢查指定的 URL 是否符合規則和條件,並在相符專案上修改 HttpContext。

UseRouter(IApplicationBuilder, Action<IRouteBuilder>)

在指定IApplicationBuilder中加入RouterMiddleware一個中介軟體,並設定IRouterIRouteBuilder了 build from。

UseRouter(IApplicationBuilder, IRouter)

在指定的 IApplicationBuilderIRouter中介軟體中加入 RouterMiddleware

UseRouting(IApplicationBuilder)

在指定的 IApplicationBuilder 中新增一個 Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware 中介軟體。

UseSession(IApplicationBuilder, SessionOptions)

新增 以 SessionMiddleware 自動啟用應用程式的會話狀態。

UseSession(IApplicationBuilder)

新增 以 SessionMiddleware 自動啟用應用程式的會話狀態。

UseSpa(IApplicationBuilder, Action<ISpaBuilder>)

傳回單一頁面應用程式的默認頁面,以處理中間件鏈結中這個點的所有要求。

此中間件應該放在鏈結中後期,讓其他中間件提供靜態檔案、MVC 動作等的優先順序較高。

UseSpaStaticFiles(IApplicationBuilder, StaticFileOptions)

設定應用程式為單頁應用程式 (SPA) 提供靜態檔案。 檔案將透過註冊 ISpaStaticFileProvider 服務被定位。

UseSpaStaticFiles(IApplicationBuilder)

設定應用程式為單頁應用程式 (SPA) 提供靜態檔案。 檔案將透過註冊 ISpaStaticFileProvider 服務被定位。

UseStaticFiles(IApplicationBuilder, StaticFileOptions)

使用指定的選項啟用靜態檔案服務

UseStaticFiles(IApplicationBuilder, String)

啟用指定要求路徑的靜態檔案服務

UseStaticFiles(IApplicationBuilder)

啟用目前要求路徑的靜態檔案服務

UseStatusCodePages(IApplicationBuilder, Action<IApplicationBuilder>)

使用指定的替代中間件管線,將 StatusCodePages 中間件新增至管線,以產生響應主體。

UseStatusCodePages(IApplicationBuilder, Func<StatusCodeContext,Task>)

新增具有指定處理程式的 StatusCodePages 中間件,以檢查 400 到 599 之間沒有本文之狀態代碼的回應。

UseStatusCodePages(IApplicationBuilder, StatusCodePagesOptions)

新增具有指定選項的 StatusCodePages 中間件,以檢查具有 400 到 599 之間沒有本文之狀態代碼的回應。 若 HandleAsync 使用預設值,則嘗試產生 ProblemDetails 回應 IProblemDetailsService ,並回退至包含狀態碼的純文字回應。

UseStatusCodePages(IApplicationBuilder, String, String)

新增具有要傳送之指定響應主體的 StatusCodePages 中間件。 這可能包含狀態碼的「{0}''佔位符。 中間件會檢查狀態代碼介於 400 到 599 之間沒有本文的回應。

UseStatusCodePages(IApplicationBuilder)

用預設的回應處理器加入 a StatusCodePagesMiddleware 。 中介軟體會檢查狀態碼介於 400 到 599 之間且沒有實體的回應,當有 時 IProblemDetailsService ,嘗試產生 ProblemDetails 回應。 若服務無法使用或無法撰寫回應,則會產生包含狀態碼的純文字回應。

UseStatusCodePagesWithRedirects(IApplicationBuilder, String)

將 StatusCodePages 中間件新增至管線。 指定應該使用指定的位置 URL 範本重新導向來處理回應。 這可能包含狀態碼的「{0}''佔位符。 開頭為 『~』 的 URL 前面會加上 PathBase,其中任何其他 URL 都會像往常一樣使用。

UseStatusCodePagesWithReExecute(IApplicationBuilder, String, String, Boolean)

將 StatusCodePages 中間件新增至管線。 指定應該使用替代路徑重新執行要求管線來產生響應主體。 此路徑可能包含狀態碼的「{0}''佔位符。

UseStatusCodePagesWithReExecute(IApplicationBuilder, String, String)

將 StatusCodePages 中間件新增至管線。 指定應該使用替代路徑重新執行要求管線來產生響應主體。 此路徑可能包含狀態碼的「{0}''佔位符。

UseW3CLogging(IApplicationBuilder)

新增中間件,以 W3C 格式記錄伺服器記錄的 HTTP 要求和回應。

UseWebAssemblyDebugging(IApplicationBuilder)

在 Chromium 開發工具中新增偵錯 Blazor WebAssembly 應用程式所需的中間件。

UseWebSockets(IApplicationBuilder, WebSocketOptions)

將 加入 WebSocketMiddleware 請求管線。

UseWebSockets(IApplicationBuilder)

將 加入 WebSocketMiddleware 請求管線。

UseWelcomePage(IApplicationBuilder, PathString)

將 WelcomePageMiddleware 新增至具有指定路徑的管線。

UseWelcomePage(IApplicationBuilder, String)

將 WelcomePageMiddleware 新增至具有指定路徑的管線。

UseWelcomePage(IApplicationBuilder, WelcomePageOptions)

將 WelcomePageMiddleware 新增至具有指定選項的管線。

UseWelcomePage(IApplicationBuilder)

將 WelcomePageMiddleware 新增至管線。

UseWhen(IApplicationBuilder, Func<HttpContext,Boolean>, Action<IApplicationBuilder>)

有條件地在要求管線中建立分支,該分支會重新加入主要管線。

適用於