-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-minimal-actionsController-like actions for endpoint routingController-like actions for endpoint routingold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels
Milestone
Description
Describe the bug
Today we add routes from the WebApplication we copy the route data sources to the last call to UseEndpoints, this results in bizzare behavior when adding multiple calls to UseRouting and UseEndpoints.
To Reproduce
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.UseRouting();
app.Use((context, next) =>
{
Console.WriteLine("Selected endpoint is " + (context.GetEndpoint()?.DisplayName is string s ? s : "null"));
return next(context);
});
app.MapGet("/", () => "Hello World");
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/hi", () => "Hello Endpoints");
});
app.UseRouting();
app.UseEndpoints(_ => { });
app.Run();If you request / you'll see "Selected endpoints is null". It's because the middleware runs after the first UseRouting middleware but the route is matched in the second UseRouting middleware.
Metadata
Metadata
Assignees
Labels
area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-minimal-actionsController-like actions for endpoint routingController-like actions for endpoint routingold-area-web-frameworks-do-not-use*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels*DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels