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

Advertisements