I have below controller structure -
1. ValuesController : Controller
2. ValuesV2Controller : ValuesController
3. ValuesV3Controller : ValuesV2Controller
4. ValuesV4Controller : ValuesV3Controller
All controllers having one common method Get(Type value); to get a particular record. Type of value differs in every controller.
I have implemented versioning in ASP.NET Core Web APIs with Microsoft.AspNetCore.Mvc.Versioning Nugget.
In startup > Configure services; included below set of code :
services.AddApiVersioning(o =>
{
o.ApiVersionReader = new HeaderApiVersionReader("x-lz-api-
version");
o.DefaultApiVersion = new ApiVersion(1, 0);
o.ReportApiVersions = true;
o.AssumeDefaultVersionWhenUnspecified = true;
});
When we invoke V1, V2, V3 APIs then it gives 500 not found an error, specifically for Versioning performed with custom Header.
Tried out below possible solutions: 1. Making base class virtual and overriding derived classes from them, but as type differs, it doesn't work. 2. This problem doesn't occur for URL versioning, this is very specific to custom header versioning.
What I have tried:
Tried out below possible solutions:
1. Making base class virtual and overriding derived classes from them, but as type differs, it doesn't work.
2. This problem doesn't occur for URL versioning, this is very specific to custom header versioning.