I have an ASP.NET MVC 4 app. I want to use the new Web API feature for learning purposes. I want to learn how to expose the same endpoint, but provide different versions of it.
Sebastiaan Dammann has, on his blog, described how he did Web API versioning by writing his own implementation of IHttpControllerSelector
and supporting interfaces.
http://damsteen.nl/blog/implementing-versioning-in-asp.net-web-api
He's also put the code on github
https://github.com/Sebazzz/SDammann.WebApi.Versioning
And packaged it in NuGet for us! :)
https://nuget.org/packages/SDammann.WebApi.Versioning
While implementing IHttpControllerSelector
is certainly (imho) the Right Way to do Web API versioning, I think it would be ideal if he included the ability to version based on the HTTP (see http://barelyenough.org/blog/2008/05/versioning-rest-web-services/).Accept
header
Unfortunately my client side is unable to work with the Accept
header, so his RouteVersionedControllerSelector
is ideal for me.
Edit: Not sure how I missed it, but there is indeed an AcceptHeaderVersionedControllerSelector
that can be used to do versioning the ideal way. I'm currently using it on a new project, but it still has some drawbacks