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.

C#
public static Microsoft.AspNetCore.Builder.RouteHandlerBuilder MapFallback (this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, Delegate handler);

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

ASP.NET Core 9.0 dan versi lain
Produk Versi
ASP.NET Core 6.0, 7.0, 8.0, 9.0

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.

C#
public static Microsoft.AspNetCore.Builder.RouteHandlerBuilder MapFallback (this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string pattern, Delegate handler);

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

ASP.NET Core 9.0 dan versi lain
Produk Versi
ASP.NET Core 6.0, 7.0, 8.0, 9.0