Skip to content

The "pattern" paramter of Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.MapFallback is ignored when EnableRequestDelegateGenerator is true #65992

@johanpolson

Description

@johanpolson

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

The pattern paramter of Microsoft.AspNetCore.Builder.EndpointRouteBuilderExtensions.MapFallback is ignored when EnableRequestDelegateGenerator is true

This means that the following code only works when EnableRequestDelegateGenerator is set to false

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

app.MapFallback("{*path}", (HttpContext context) => "this is {*path}");
app.MapFallback("{*path:nonfile}", (HttpContext context) => "this is {*path:nonfile}");

app.Run();

but if I run the code with EnableRequestDelegateGenerator set to true 😥

Connection id "0HNKBFUONIV8B", Request id "0HNKBFUONIV8B:00000003": An unhandled exception was thrown by the application.
Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches:

{*path:nonfile}
{*path:nonfile}
           at Microsoft.AspNetCore.Routing.Matching.DefaultEndpointSelector.ReportAmbiguity(Span`1 candidateState)

.NET Version

11.0.100-preview.2.26159.112

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-rdg

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions