共用方式為


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
實作

屬性

Configuration

應用程式設定 IConfiguration

Environment

應用程式設定 IWebHostEnvironment

Lifetime

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

Logger

應用程式的預設記錄器。

Services

應用程式的已設定服務。

Urls

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

方法

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>)

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

明確介面實作

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 應用程式。

擴充方法

UseAntiforgery(IApplicationBuilder)

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

UseRequestLocalization(IApplicationBuilder)

新增 RequestLocalizationMiddleware,以根據用戶端提供的資訊自動設定要求的文化特性資訊。

UseRequestLocalization(IApplicationBuilder, RequestLocalizationOptions)

新增 RequestLocalizationMiddleware,以根據用戶端提供的資訊自動設定要求的文化特性資訊。

UseRequestLocalization(IApplicationBuilder, Action<RequestLocalizationOptions>)

新增 RequestLocalizationMiddleware,以根據用戶端提供的資訊自動設定要求的文化特性資訊。

UseRequestLocalization(IApplicationBuilder, String[])

新增 RequestLocalizationMiddleware,以根據用戶端提供的資訊自動設定要求的文化特性資訊。

UseAuthentication(IApplicationBuilder)

AuthenticationMiddleware 新增至指定的 IApplicationBuilder,以啟用驗證功能。

UseAuthorization(IApplicationBuilder)

AuthorizationMiddleware 新增至指定的 IApplicationBuilder,以啟用授權功能。

授權使用端點路由路由傳送的資源時,此呼叫必須出現在呼叫 app.UseRouting()app.UseEndpoints(...) 之間,中間件才能正常運作。

UseCertificateForwarding(IApplicationBuilder)

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

MapBlazorHub(IEndpointRouteBuilder)

將 Blazor Hub 對應至預設路徑。

MapBlazorHub(IEndpointRouteBuilder, Action<HttpConnectionDispatcherOptions>)

將 Blazor Hub 對應至預設路徑。

MapBlazorHub(IEndpointRouteBuilder, String)

將 Blazor Hub 對應至路徑 path

MapBlazorHub(IEndpointRouteBuilder, String, Action<HttpConnectionDispatcherOptions>)

將 Blazor Hub 對應至路徑 path

UseBlazorFrameworkFiles(IApplicationBuilder)

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

UseBlazorFrameworkFiles(IApplicationBuilder, PathString)

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

UseConcurrencyLimiter(IApplicationBuilder)
已淘汰.

新增 ConcurrencyLimiterMiddleware,以限制同時執行的要求數目。

MapConnectionHandler<TConnectionHandler>(IEndpointRouteBuilder, String)

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

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

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

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

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

MapConnections(IEndpointRouteBuilder, String, Action<IConnectionBuilder>)

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

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

將控制器動作的端點新增至 IEndpointRouteBuilder,並指定具有指定 nameareaNamepatterndefaultsconstraintsdataTokens的路由。

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

將控制器動作的端點新增至 IEndpointRouteBuilder,並指定具有指定 namepatterndefaultsconstraintsdataTokens的路由。

MapControllers(IEndpointRouteBuilder)

將控制器動作的端點新增至 IEndpointRouteBuilder,而不指定任何路由。

MapDefaultControllerRoute(IEndpointRouteBuilder)

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

MapDynamicControllerRoute<TTransformer>(IEndpointRouteBuilder, String)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,該 IEndpointRouteBuilder 會嘗試使用 TTransformer所產生的路由值來選取控制器動作。

MapDynamicControllerRoute<TTransformer>(IEndpointRouteBuilder, String, Object)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,該 IEndpointRouteBuilder 會嘗試使用 TTransformer所產生的路由值來選取控制器動作。

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

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,該 IEndpointRouteBuilder 會嘗試使用 TTransformer所產生的路由值來選取控制器動作。

MapFallbackToAreaController(IEndpointRouteBuilder, String, String, String)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合非檔名的要求,且優先順序最低。 要求會路由傳送至符合 actioncontrollerarea的控制器端點。

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

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合非檔名的要求,且優先順序最低。 要求會路由傳送至符合 actioncontrollerarea的控制器端點。

MapFallbackToController(IEndpointRouteBuilder, String, String)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合非檔名的要求,且優先順序最低。 要求會路由傳送至符合 action的控制器端點,並 controller

MapFallbackToController(IEndpointRouteBuilder, String, String, String)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合非檔名的要求,且優先順序最低。 要求會路由傳送至符合 action的控制器端點,並 controller

UseCookiePolicy(IApplicationBuilder)

CookiePolicyMiddleware 處理程式新增至指定的 IApplicationBuilder,以啟用 Cookie 原則功能。

UseCookiePolicy(IApplicationBuilder, CookiePolicyOptions)

CookiePolicyMiddleware 處理程式新增至指定的 IApplicationBuilder,以啟用 Cookie 原則功能。

UseCors(IApplicationBuilder)

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

UseCors(IApplicationBuilder, Action<CorsPolicyBuilder>)

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

UseCors(IApplicationBuilder, String)

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

UseDatabaseErrorPage(IApplicationBuilder)
已淘汰.

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

UseDatabaseErrorPage(IApplicationBuilder, DatabaseErrorPageOptions)
已淘汰.

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

UseDefaultFiles(IApplicationBuilder)

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

UseDefaultFiles(IApplicationBuilder, DefaultFilesOptions)

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

UseDefaultFiles(IApplicationBuilder, String)

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

UseDeveloperExceptionPage(IApplicationBuilder)

從管線擷取同步和異步 Exception 實例,併產生 HTML 錯誤回應。

UseDeveloperExceptionPage(IApplicationBuilder, DeveloperExceptionPageOptions)

從管線擷取同步和異步 Exception 實例,併產生 HTML 錯誤回應。

UseDirectoryBrowser(IApplicationBuilder)

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

UseDirectoryBrowser(IApplicationBuilder, DirectoryBrowserOptions)

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

UseDirectoryBrowser(IApplicationBuilder, String)

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

Map(IEndpointRouteBuilder, RoutePattern, RequestDelegate)

RouteEndpoint 加入至符合指定模式之 HTTP 要求的 IEndpointRouteBuilder

Map(IEndpointRouteBuilder, RoutePattern, Delegate)

RouteEndpoint 加入至符合指定模式之 HTTP 要求的 IEndpointRouteBuilder

Map(IEndpointRouteBuilder, String, RequestDelegate)

RouteEndpoint 加入至符合指定模式之 HTTP 要求的 IEndpointRouteBuilder

Map(IEndpointRouteBuilder, String, Delegate)

RouteEndpoint 加入至符合指定模式之 HTTP 要求的 IEndpointRouteBuilder

MapDelete(IEndpointRouteBuilder, String, RequestDelegate)

RouteEndpoint 加入至符合指定模式之 HTTP DELETE 要求的 IEndpointRouteBuilder

MapDelete(IEndpointRouteBuilder, String, Delegate)

RouteEndpoint 加入至符合指定模式之 HTTP DELETE 要求的 IEndpointRouteBuilder

MapFallback(IEndpointRouteBuilder, Delegate)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合非檔名的要求,且優先順序最低。

MapFallback(IEndpointRouteBuilder, String, Delegate)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合所提供模式且優先順序最低。

MapGet(IEndpointRouteBuilder, String, RequestDelegate)

RouteEndpoint 加入至符合指定模式之 HTTP GET 要求的 IEndpointRouteBuilder

MapGet(IEndpointRouteBuilder, String, Delegate)

RouteEndpoint 加入至符合指定模式之 HTTP GET 要求的 IEndpointRouteBuilder

MapGroup(IEndpointRouteBuilder, RoutePattern)

建立 RouteGroupBuilder,以定義所有前面加上指定 prefix的端點。

MapGroup(IEndpointRouteBuilder, String)

建立 RouteGroupBuilder,以定義所有前面加上指定 prefix的端點。

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

RouteEndpoint 加入至符合指定 HTTP 方法和模式之 HTTP 要求的 IEndpointRouteBuilder

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

RouteEndpoint 加入至符合指定 HTTP 方法和模式之 HTTP 要求的 IEndpointRouteBuilder

MapPatch(IEndpointRouteBuilder, String, RequestDelegate)

RouteEndpoint 新增至符合指定模式之 HTTP PATCH 要求的 IEndpointRouteBuilder

MapPatch(IEndpointRouteBuilder, String, Delegate)

RouteEndpoint 新增至符合指定模式之 HTTP PATCH 要求的 IEndpointRouteBuilder

MapPost(IEndpointRouteBuilder, String, RequestDelegate)

RouteEndpoint 加入至符合指定模式之 HTTP POST 要求的 IEndpointRouteBuilder

MapPost(IEndpointRouteBuilder, String, Delegate)

RouteEndpoint 加入至符合指定模式之 HTTP POST 要求的 IEndpointRouteBuilder

MapPut(IEndpointRouteBuilder, String, RequestDelegate)

RouteEndpoint 加入至符合指定模式之 HTTP PUT 要求的 IEndpointRouteBuilder

MapPut(IEndpointRouteBuilder, String, Delegate)

RouteEndpoint 加入至符合指定模式之 HTTP PUT 要求的 IEndpointRouteBuilder

UseEndpoints(IApplicationBuilder, Action<IEndpointRouteBuilder>)

Microsoft.AspNetCore.Routing.EndpointMiddleware 中間件新增至指定的 IApplicationBuilder,並使用從設定的 IEndpointRouteBuilder建置的 EndpointDataSource 實例。 Microsoft.AspNetCore.Routing.EndpointMiddleware 會執行與目前要求相關聯的 Endpoint

UseRouting(IApplicationBuilder)

Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware 中間件新增至指定的 IApplicationBuilder

UseExceptionHandler(IApplicationBuilder)

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

UseExceptionHandler(IApplicationBuilder, ExceptionHandlerOptions)

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

UseExceptionHandler(IApplicationBuilder, Action<IApplicationBuilder>)

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

UseExceptionHandler(IApplicationBuilder, String)

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

UseExceptionHandler(IApplicationBuilder, String, Boolean)

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

MapFallback(IEndpointRouteBuilder, RequestDelegate)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合非檔名的要求,且優先順序最低。

MapFallback(IEndpointRouteBuilder, String, RequestDelegate)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合所提供模式且優先順序最低。

UseFileServer(IApplicationBuilder)

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

UseFileServer(IApplicationBuilder, FileServerOptions)

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

UseFileServer(IApplicationBuilder, Boolean)

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

UseFileServer(IApplicationBuilder, String)

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

UseForwardedHeaders(IApplicationBuilder)

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

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

UseForwardedHeaders(IApplicationBuilder, ForwardedHeadersOptions)

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

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

UseHeaderPropagation(IApplicationBuilder)

新增收集要傳播至 HttpClient標頭的中間件。

UseHealthChecks(IApplicationBuilder, PathString)

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

UseHealthChecks(IApplicationBuilder, PathString, HealthCheckOptions)

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

UseHealthChecks(IApplicationBuilder, PathString, Int32)

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

UseHealthChecks(IApplicationBuilder, PathString, Int32, HealthCheckOptions)

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

UseHealthChecks(IApplicationBuilder, PathString, String)

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

UseHealthChecks(IApplicationBuilder, PathString, String, HealthCheckOptions)

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

MapHealthChecks(IEndpointRouteBuilder, String)

使用指定的範本,將健康情況檢查端點新增至 IEndpointRouteBuilder

MapHealthChecks(IEndpointRouteBuilder, String, HealthCheckOptions)

使用指定的範本和選項,將健康情況檢查端點新增至 IEndpointRouteBuilder

UseHostFiltering(IApplicationBuilder)

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

UseHsts(IApplicationBuilder)

新增使用 HSTS 的中間件,以新增 Strict-Transport-Security 標頭。

UseHttpLogging(IApplicationBuilder)

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

UseW3CLogging(IApplicationBuilder)

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

UseHttpMethodOverride(IApplicationBuilder)

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

UseHttpMethodOverride(IApplicationBuilder, HttpMethodOverrideOptions)

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

UseHttpsRedirection(IApplicationBuilder)

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

MapHub<THub>(IEndpointRouteBuilder, String)

將內送要求對應至指定 Hub 型別的指定路徑。

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

將內送要求對應至指定 Hub 型別的指定路徑。

Map(IApplicationBuilder, PathString, Action<IApplicationBuilder>)

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

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

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

Map(IApplicationBuilder, String, Action<IApplicationBuilder>)

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

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

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

UseMigrationsEndPoint(IApplicationBuilder)

處理執行移轉作業的要求。 中間件會接聽對 DefaultPath提出的要求。

UseMigrationsEndPoint(IApplicationBuilder, MigrationsEndPointOptions)

處理執行移轉作業的要求。 中間件會接聽 options中所設定路徑的要求。

UseMvc(IApplicationBuilder)

將MVC新增至 IApplicationBuilder 要求執行管線。

UseMvc(IApplicationBuilder, Action<IRouteBuilder>)

將MVC新增至 IApplicationBuilder 要求執行管線。

UseMvcWithDefaultRoute(IApplicationBuilder)

使用名為 'default' 的預設路由,將 MVC 新增至 IApplicationBuilder 要求執行管線,以及下列範本:'{controller=Home}/{action=Index}/{id?}'。

MapOpenApi(IEndpointRouteBuilder, String)

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

UseOutputCache(IApplicationBuilder)

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

UseOwin(IApplicationBuilder)

將 OWIN 管線新增至指定的 IApplicationBuilder

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

將 OWIN 中間件管線新增至指定的 IApplicationBuilder

UseRateLimiter(IApplicationBuilder)

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

UseRateLimiter(IApplicationBuilder, RateLimiterOptions)

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

MapRazorComponents<TRootComponent>(IEndpointRouteBuilder)

將指定 TRootComponent 中定義的頁面元件對應至指定的元件,並在路由相符時轉譯 TRootComponent 指定的元件。

MapDynamicPageRoute<TTransformer>(IEndpointRouteBuilder, String)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以嘗試使用 TTransformer所產生的路由值來選取頁面。

MapDynamicPageRoute<TTransformer>(IEndpointRouteBuilder, String, Object)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以嘗試使用 TTransformer所產生的路由值來選取頁面。

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

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以嘗試使用 TTransformer所產生的路由值來選取頁面。

MapFallbackToAreaPage(IEndpointRouteBuilder, String, String)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合非檔名的要求,且優先順序最低。 要求會路由傳送至符合 page的頁面端點,並 area

MapFallbackToAreaPage(IEndpointRouteBuilder, String, String, String)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合非檔名的要求,且優先順序最低。 要求會路由傳送至符合 page的頁面端點,並 area

MapFallbackToPage(IEndpointRouteBuilder, String)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合非檔名的要求,且優先順序最低。 要求將會路由傳送至符合 page的頁面端點。

MapFallbackToPage(IEndpointRouteBuilder, String, String)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合非檔名的要求,且優先順序最低。 要求將會路由傳送至符合 page的頁面端點。

MapRazorPages(IEndpointRouteBuilder)

將 Razor Pages 的端點新增至 IEndpointRouteBuilder

UseRequestDecompression(IApplicationBuilder)

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

UseRequestTimeouts(IApplicationBuilder)

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

預設不會設定逾時。 它們必須設定在 RequestTimeoutOptions、端點上的 RequestTimeoutAttribute,或使用WithRequestTimeout路由延伸模組。

UseResponseCaching(IApplicationBuilder)

新增快取 HTTP 回應的 ResponseCachingMiddleware

UseResponseCompression(IApplicationBuilder)

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

UseRewriter(IApplicationBuilder)

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

UseRewriter(IApplicationBuilder, RewriteOptions)

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

UseRouter(IApplicationBuilder, IRouter)

使用指定的 IRouter,將 RouterMiddleware 中間件新增至指定的 IApplicationBuilder

UseRouter(IApplicationBuilder, Action<IRouteBuilder>)

使用從設定的 IRouteBuilder建置 IRouter,將 RouterMiddleware 中間件新增至指定的 IApplicationBuilder

Run(IApplicationBuilder, RequestDelegate)

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

UseSession(IApplicationBuilder)

新增 SessionMiddleware 以自動啟用應用程式的工作階段狀態。

UseSession(IApplicationBuilder, SessionOptions)

新增 SessionMiddleware 以自動啟用應用程式的工作階段狀態。

UseSpa(IApplicationBuilder, Action<ISpaBuilder>)

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

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

UseStaticFiles(IApplicationBuilder)

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

UseStaticFiles(IApplicationBuilder, StaticFileOptions)

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

UseStaticFiles(IApplicationBuilder, String)

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

MapFallbackToFile(IEndpointRouteBuilder, String)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合非檔名的要求,且優先順序最低。 要求會路由傳送至嘗試提供 filePath所指定檔案的 StaticFileMiddleware

MapFallbackToFile(IEndpointRouteBuilder, String, StaticFileOptions)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合非檔名的要求,且優先順序最低。 要求會路由傳送至嘗試提供 filePath所指定檔案的 StaticFileMiddleware

MapFallbackToFile(IEndpointRouteBuilder, String, String)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合非檔名的要求,且優先順序最低。 要求會路由傳送至嘗試提供 filePath所指定檔案的 StaticFileMiddleware

MapFallbackToFile(IEndpointRouteBuilder, String, String, StaticFileOptions)

將特製化 RouteEndpoint 新增至 IEndpointRouteBuilder,以符合非檔名的要求,且優先順序最低。 要求會路由傳送至嘗試提供 filePath所指定檔案的 StaticFileMiddleware

UseStatusCodePages(IApplicationBuilder)

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

UseStatusCodePages(IApplicationBuilder, StatusCodePagesOptions)

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

UseStatusCodePages(IApplicationBuilder, Action<IApplicationBuilder>)

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

UseStatusCodePages(IApplicationBuilder, Func<StatusCodeContext,Task>)

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

UseStatusCodePages(IApplicationBuilder, String, String)

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

UseStatusCodePagesWithRedirects(IApplicationBuilder, String)

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

UseStatusCodePagesWithReExecute(IApplicationBuilder, String, String)

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

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);
});

UseMiddleware(IApplicationBuilder, Type, Object[])

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

UseMiddleware<TMiddleware>(IApplicationBuilder, Object[])

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

UsePathBase(IApplicationBuilder, PathString)

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

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

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

UseWebAssemblyDebugging(IApplicationBuilder)

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

UseWebSockets(IApplicationBuilder)

WebSocketMiddleware 新增至要求管線。

UseWebSockets(IApplicationBuilder, WebSocketOptions)

WebSocketMiddleware 新增至要求管線。

UseWelcomePage(IApplicationBuilder)

將 WelcomePageMiddleware 新增至管線。

UseWelcomePage(IApplicationBuilder, WelcomePageOptions)

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

UseWelcomePage(IApplicationBuilder, PathString)

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

UseWelcomePage(IApplicationBuilder, String)

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

MapIdentityApi<TUser>(IEndpointRouteBuilder)

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

MapShortCircuit(IEndpointRouteBuilder, Int32, String[])

RouteEndpoint 加入至符合指定前置詞之 HTTP 要求(所有動詞)的 IEndpointRouteBuilder

UseHttpLoggingMiddleware(IApplicationBuilder)

將傳入的 HTTP 要求記錄中間件註冊至 IApplicationBuilder

UseRequestCheckpoint(IApplicationBuilder)

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

UseRequestLatencyTelemetry(IApplicationBuilder)

將要求延遲遙測中間件新增至 IApplicationBuilder 要求執行管線。

UseSpaStaticFiles(IApplicationBuilder)

設定應用程式為單頁應用程式 (SPA) 提供靜態檔案。 檔案會使用已註冊的 ISpaStaticFileProvider 服務來找到。

UseSpaStaticFiles(IApplicationBuilder, StaticFileOptions)

設定應用程式為單頁應用程式 (SPA) 提供靜態檔案。 檔案會使用已註冊的 ISpaStaticFileProvider 服務來找到。

適用於