Fanie Reynders
Fanie Reynders

Reputation: 580

Versioning in ASP.NET Wep API

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?

Upvotes: 1

Views: 961

Answers (1)

Sebazzz
Sebazzz

Reputation: 1373

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

Upvotes: 2

Related Questions