Closed Saibamen closed 10 months ago
This option still exists, but it is now only set through dependency injection (DI). Web API doesn't have out-of-the-box DI support so the option needs to be explicit in the options. In ASP.NET Core, Minimal APIs and MVC Core are separated by the AddApiVersioning()
and AddMvc()
respectively. I considered moving ControllerNameConvention
over to the MVC Core options, but I really wanted to reduce the number of configurable options which are better suited for DI. In fact, the naming convention could always be set via DI. Setting it via the options was a secondary way.
You can find the source at:
To achieve your desired configuration, you need only set or replace the service you want to use:
builder.Services.AddSingleton<IControllerNameConvention, OriginalControllerNameConvention>();
In fairness, I missed adding this change to the migration guide. I have updated the section on configuration to note this difference.
I hope that helps.
Thank you. It works :)
Is there an existing issue for this?
Describe the bug
We fixed one bug in our Legacy (but still in active development) .NET Framework WebAPI by setting
ControllerNameConvention = new OriginalControllerNameConvention();
.Now I want to do the same in .NET Core WebAPI, but
IControllerNameConvention
is missing inApiVersioningOptions.cs
....NET Framework NuGet name and version:
Microsoft.AspNet.WebApi.Versioning
5.1.0 .NET Core NuGet name and version:Asp.Versioning.Mvc.ApiExplorer
7.1.0Expected Behavior
.NET Core should have all options from official documentation. Controller name should be
PrintV2
in Swagger in .NET Core.Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version
8.0.100-rc.2.23502.2
Anything else?
.NET Core 7.0.13