Click here to Skip to main content
14,236,057 members
Rate this:
Please Sign up or sign in to vote.
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.
Posted
Updated 14-May-19 1:07am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100