DEV Community

loading...

Discussion on: REST API versioning with ASP.NET Core

Collapse
dishanx profile image
Dishan

Good post.
Is it possible to use URL path versioning and header API versioning combination? I added URL versioning support to my API but it breaks access to the old URL(api/authors). now I have to specify version in the URL(api/v1.0/authors). but some of the client apps use that old URL. are there any solutions for that?

Collapse
prayatna profile image
Prayatna Bhattarai

You can try adding two url paths like
[Route("api/[controller]")]
[Route("api/v{version:apiVersion}/[controller]")]
for your base controller so that it uses both url

Collapse
99darshan profile image
99darshan Author

Yes you could use multiple versioning schemes. Supporting multiple versioning Schemes section in this article has an example on how to implement both the query params versioning scheme and request header versioning scheme.