Description
Description
Starting in .NET 6 RC2, behavior that was introduced in .NET 6 RC1 to automatically set the IEndpointNameMetadata
for endpoints has been reverted to avoid issues the logic generating duplicate endpoint names.
Version
.NET 6 RC 2
Previous behavior
In .NET 6 RC1 and above, the IEndpointNameMetadata
was automatically set for endpoints that referenced a method group. For example, the following code:
app.MapGet("/foo", GetFoo);
Would produce an endpoint for /foo
with a EndpointName
set to "GetFoo".
New behavior
In .NET 6 RC 2 and onward, the IEndpointNameMetadata
is no longer set. For example, the following code:
app.MapGet("/foo", GetFoo);
would not generated any IEndpointNameMetadat
.
Type of breaking change
- Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
- Source incompatible: Source code may encounter a breaking change in behavior when targeting the new runtime/component/SDK, such as compile errors or different run-time behavior.
Reason for change
The behavior of automatically setting endpoint name metadata was not robust and resulted in issues where the same name was set for different endpoints. See dotnet/aspnetcore#36487 for more info.
Recommended action
We recommend that developers manually set the IEndpointNameMetadata
using the WithName
extension method as follows to set the metadata.
app.MapGet("/foo", GetFoo).WithName("GetFoo");
Feature area
ASP.NET Core
Affected APIs
No response