I have an ASP.NET MVC 4 app. I want to use the new Web API feature for learning purposes. I want to learn how to expose the same endpoint, but provide different versions of it.
If we are going your 1st approach then it helps to route and allow us to get the data for V1, V2.... but now we have taken an example of v1 and v2 for one controller so routing code will be as below:
config.Routes.MapHttpRoute(
name: "1-0Api",
routeTemplate: "tables/v1/Products",
defaults: new { controller = "ProductsV1", id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "2-0Api",
routeTemplate: "tables/v2/Products",
defaults: new { controller = "ProductsV2", id = RouteParameter.Optional }
);
But we have more than 20 controllers and multiple versions then how to make it generic.