EndpointRouteBuilderExtensions.MapFallback Method

Definition

Overloads

MapFallback(IEndpointRouteBuilder, Delegate)

Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match requests for non-file-names with the lowest possible priority.

MapFallback(IEndpointRouteBuilder, String, Delegate)

Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match the provided pattern with the lowest possible priority.

MapFallback(IEndpointRouteBuilder, Delegate)

Source:
EndpointRouteBuilderExtensions.cs

Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match requests for non-file-names with the lowest possible priority.

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

Parameters

endpoints
IEndpointRouteBuilder

The IEndpointRouteBuilder to add the route to.

handler
Delegate

The delegate executed when the endpoint is matched.

Returns

A RouteHandlerBuilder that can be used to further customize the endpoint.

Remarks

MapFallback(IEndpointRouteBuilder, Delegate) is intended to handle cases where URL path of the request does not contain a file name, and no other endpoint has matched. This is convenient for routing requests for dynamic content to a SPA framework, while also allowing requests for non-existent files to result in an HTTP 404.

MapFallback(IEndpointRouteBuilder, Delegate) registers an endpoint using the pattern {*path:nonfile}. The order of the registered endpoint will be int.MaxValue.

Applies to

MapFallback(IEndpointRouteBuilder, String, Delegate)

Source:
EndpointRouteBuilderExtensions.cs

Adds a specialized RouteEndpoint to the IEndpointRouteBuilder that will match the provided pattern with the lowest possible priority.

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

Parameters

endpoints
IEndpointRouteBuilder

The IEndpointRouteBuilder to add the route to.

pattern
String

The route pattern.

handler
Delegate

The delegate executed when the endpoint is matched.

Returns

A RouteHandlerBuilder that can be used to further customize the endpoint.

Remarks

MapFallback(IEndpointRouteBuilder, String, Delegate) is intended to handle cases where no other endpoint has matched. This is convenient for routing requests to a SPA framework.

The order of the registered endpoint will be int.MaxValue.

This overload will use the provided pattern verbatim. Use the :nonfile route constraint to exclude requests for static files.

Applies to