Web API Versioning (using Header) – Part 2

Introduction

In this post, I am going to discuss Web API versioning using custom Header. We are already discussed versioning using URI i.e.  namespace based versioning.

How versioning through Header?

To perform versioning through HTTP Header, we set a Header in request to differentiate API resources and on the server we have to check the Header and execute the controller that is specified by Header value.

Continue reading

Advertisements

Web API Versioning (using NameSpaceControllerSelector) – Part 1

 

Introduction

In this article, I am going to discuss Versioning of Web API, its needs, approaches used for versioning and how we can implement that.

Why we need Versioning?

API versioning is very much required if we are exposing our services for the public, so it need to be our API should be forward and backward compatibility. By versioning, API  don’t affect the existing functionality and break user application which depends on our API.

How we are going to do this?

In the Web API default routing implementation map routes to the controller by ControllerClass name. Internally Web API select controller, for route, through DefaultControllerSelector which implement IHttpControllerSelector.SelectController. Using default controller selector we can’t really version web API, but we can implement our custom selector to select right version of our controller. We can easily create a custom HTTP controller selector by implementing IHttpControllerSelector.

Continue reading