-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-routinginvestigate
Milestone
Description
Describe the bug
ModelEndpointDataSource.Endpoints.getter is not idempotent.
Since DefaultEndpointConventionBuilder.Build() doesn't use another copy / clone of the original EndpointBuilder, if the _conventions is not empty, the convention will be applied one more time. Something like endpointConventionBuilder.WithMetadata(new HttpMethodMetadata(new[] { "GET" })) will add the repeated metadata object into that EndpointBuilder, and the metadata collection of last built endpoint will grow larger.
The following scenarios will make the convention collection non-empty:
- endpoints.MapMethods/MapGet/MapPost/MapPut/MapFallback/...
- endpoints.Map(...).WithMetadata(...)
A new endpoint will be created when
- Use reflection and read
IOptions<RouteOptions>.Value.EndpointDataSources.SelectMany(a => a.Endpoints) - The change token of
ActionEndpointDataSourceBaseis notified (which will take the last built endpoint to Match)
Maybe we should make DefaultEndpointConventionBuilder.Build() idempotent or the result of ModelEndpointDataSource.Endpoints cached.
Further technical details
- ASP.NET Core version 3.0, 3.1, 5.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesfeature-routinginvestigate