EndpointRouteBuilderExtensions.MapFallback 方法

定义

重载

MapFallback(IEndpointRouteBuilder, Delegate)

向 添加专用 RouteEndpoint 的 , IEndpointRouteBuilder 以匹配具有可能最低优先级的非文件名的请求。

MapFallback(IEndpointRouteBuilder, String, Delegate)

向 添加一个专用 RouteEndpoint 的 , IEndpointRouteBuilder 它将与提供的模式匹配,其优先级可能最低。

MapFallback(IEndpointRouteBuilder, Delegate)

向 添加专用 RouteEndpoint 的 , IEndpointRouteBuilder 以匹配具有可能最低优先级的非文件名的请求。

public static Microsoft.AspNetCore.Builder.RouteHandlerBuilder MapFallback (this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, Delegate handler);
static member MapFallback : Microsoft.AspNetCore.Routing.IEndpointRouteBuilder * Delegate -> Microsoft.AspNetCore.Builder.RouteHandlerBuilder
<Extension()>
Public Function MapFallback (endpoints As IEndpointRouteBuilder, handler As Delegate) As RouteHandlerBuilder

参数

endpoints
IEndpointRouteBuilder

IEndpointRouteBuilder要向其添加路由的 。

handler
Delegate

终结点匹配时执行的委托。

返回

可用于 RouteHandlerBuilder 进一步自定义终结点的 。

注解

MapFallback(IEndpointRouteBuilder, Delegate) 用于处理请求的 URL 路径不包含文件名,并且没有其他终结点匹配的情况。 这便于将动态内容的请求路由到 SPA 框架,同时允许对不存在的文件的请求导致 HTTP 404。

MapFallback(IEndpointRouteBuilder, Delegate) 使用模式 {*path:nonfile}注册终结点。 已注册终结点的顺序为 int.MaxValue

适用于

MapFallback(IEndpointRouteBuilder, String, Delegate)

向 添加一个专用 RouteEndpoint 的 , IEndpointRouteBuilder 它将与提供的模式匹配,其优先级可能最低。

public static Microsoft.AspNetCore.Builder.RouteHandlerBuilder MapFallback (this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string pattern, Delegate handler);
static member MapFallback : Microsoft.AspNetCore.Routing.IEndpointRouteBuilder * string * Delegate -> Microsoft.AspNetCore.Builder.RouteHandlerBuilder
<Extension()>
Public Function MapFallback (endpoints As IEndpointRouteBuilder, pattern As String, handler As Delegate) As RouteHandlerBuilder

参数

endpoints
IEndpointRouteBuilder

IEndpointRouteBuilder要向其添加路由的 。

pattern
String

路由模式。

handler
Delegate

终结点匹配时执行的委托。

返回

可用于 RouteHandlerBuilder 进一步自定义终结点的 。

注解

MapFallback(IEndpointRouteBuilder, String, Delegate) 用于处理没有其他终结点匹配的情况。 这便于将请求路由到 SPA 框架。

已注册终结点的顺序为 int.MaxValue

此重载将使用提供的 pattern 逐字。 使用 :nonfile 路由约束排除对静态文件的请求。

适用于