-
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 etcbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-minimal-hostingfeature-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
Adding routes top level and via UseEndpoints duplicated the routes globally. This is because the WebApplicationBuilder internally calls UseEndpoints which results in the datasource being copied twice. This may have performance implications on any code that looks at EndPointDataSource to perform actions (like link generation).
To Reproduce
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.UseRouting();
app.MapGet("/", () => "Hello World!");
app.UseEndpoints(routes =>
{
routes.MapGet("/hi", () => "Hi World");
routes.MapGet("/heyo", () => "Heyo World");
});
app.Start();
var ds = app.Services.GetRequiredService<EndpointDataSource>();
foreach (var e in ds.Endpoints)
{
Console.WriteLine(e.DisplayName);
}
app.WaitForShutdown();The following prints out:
/hi HTTP: GET
/heyo HTTP: GET
/hi HTTP: GET
/heyo HTTP: GET
/ HTTP: GET
Further technical details
- ASP.NET Core version: Microsoft.AspNetCore.App 6.0.0-rc.1.21406.15
cc @javiercn
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 etcbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.feature-minimal-hostingfeature-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