1

How do I handle versioning in my ASP.NET Web-Api project? I need to have certain functionality version specific:

example:

/v1/people
/v2/people/friends

How do I implement this in Web-API? Do I use different controllers or actions?

j0k
  • 22,600
  • 28
  • 79
  • 90
Fanie Reynders
  • 580
  • 3
  • 16
  • possible duplicate of [Versioning REST API of an ASP.NET MVC application](http://stackoverflow.com/questions/9197931/versioning-rest-api-of-an-asp-net-mvc-application) – Darin Dimitrov Jun 20 '12 at 08:15
  • 1
    Hi Darin, I've seen that post, but not totally sure how to implement it properly? – Fanie Reynders Jun 20 '12 at 08:22
  • Which of the many possible solutions described in the duplicate post are you having troubles with implementing? What have you tried? – Darin Dimitrov Jun 20 '12 at 08:43

1 Answers1

2

Simply said: You need to create a custom IHttpControllerSelector and register it via HttpConfiguration.Services. An IHttpControllerSelector has the responsibility for selecting a controller based on the request.

There is actually a library you can use for it: https://github.com/Sebazzz/SDammann.WebApi.Versioning http://damsteen.nl/blog/implementing-versioning-in-asp.net-web-api

Sebazzz
  • 1,205
  • 2
  • 15
  • 33