In this post, I’ll show how to extend the routing logic in ASP.NET Web API, by creating a custom controller selector. Suppose that you want to version your web API by defining URIs like the following: /api/v1/products/ /api/v2/products/ You might try to make this work by creating two different “Products” controllers, and placing them in separate namespaces: namespace MyApp.Controllers.V1 { // Version 1 controller public class ProductsController : ApiController { } } namespace MyApp.Controllers.V2 { // Version 2 controller public class ProductsController : ApiController { } } The problem with this approach is that Web API finds controllers by class name, ignoring the namespace. So there’s no way to make this work using...(read more) ...
Go to the complete details ...