aspnet / AspNetWebStack

ASP.NET MVC 5.x, Web API 2.x, and Web Pages 3.x (not ASP.NET Core)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ASP.NET Web API versioning Migrate from QueryStringApiVersionReader to UrlSegmentApiVersionReader

barbosatekBU opened this issue · comments

I'm currently looking into migrate an API versioning mechanism from using query parameter to use url fragments. However, I need to maintain backwards compatibility, so if the caller specifies the version on the query, it fulfills the new url segment on the route. My routes will go from:

[Route("articles")] to [Route("v{version:apiVersion}/articles")]

However, it seems when passing the api version as query parameter, the routing won't find the route (because the version is missing) and it will return 404.

Is there a way to support both, UrlSegmentApiVersionReader and QueryStringApiVersionReader at the same time?

Thanks