-
Notifications
You must be signed in to change notification settings - Fork 703
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot run APIs with different controller names with same ControllerName attribute after migration #1033
Comments
Have used this in the Startup.cs: services.AddApiVersioning(config =>
{
// if we don't specify an api version, assume the default version is 1.0
config.DefaultApiVersion = new ApiVersion(1, 0);
// if api version is not specified assume default version to be the one we specified earlier
config.AssumeDefaultVersionWhenUnspecified = true;
// so that we can get an api version information in the responses
config.ReportApiVersions = true;
}); |
It appears you are missing the call to Revised services.AddApiVersioning(config =>
{
// if we don't specify an api version, assume the default version is 1.0
config.DefaultApiVersion = new ApiVersion(1, 0);
// if api version is not specified assume default version to be the one we specified earlier
config.AssumeDefaultVersionWhenUnspecified = true;
// so that we can get an api version information in the responses
config.ReportApiVersions = true;
}).AddMvc(); // ← add MVC Core to support controllers
|
Thanks for all of the details. I've been able to repro your scenario, which was a bit surprising. I thought maybe I somehow introduced a "new" bug, but nothing has changed in this area in a long, long time; not even from I was able to figure out why this is happening. The Poking around in the ASP.NET Core source, I see this addition from 5 years ago: This code uses the The if ( controller.RouteValues.TryGetValue( "controller", out var name ) )
{
controller.ControllerName = name;
} It would seem the correct path is to add this logic back into the place where The crazy part is that this investigation seems to suggest that things have been broken for 5+ years. 😬 The reason it hasn't been detected is likely because the test cases use similar names rather than completely different ones; for example, The last part of this mystery is how you got it to work. You said that things were behaving as expected under |
I did check Just now:
|
Is there an existing issue for this?
Describe the bug
I have migrated from
"Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0"
To
"Asp.Versioning.Mvc" Version="6.4.0"
But after this following has stopped working;
In the above:
Where As:
Expected Behavior
This should be working since I tried to follow guide.
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
8.0.100-rc.2.23502.2
Anything else?
ASP.NET Core : 6.0
Visual Studio: Microsoft Visual Studio Enterprise 2022 (64-bit) - Preview Version 17.8.0 Preview 4.0
The text was updated successfully, but these errors were encountered: