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.
Any chance you still have the default Web API route defined and it's before your custom route? That would cause your scenario to fail. The following route definitions (note the order) worked for me.
public static void Register(HttpConfiguration config) {
config.Routes.MapHttpRoute(
name: "1-0Api",
routeTemplate: "api/1.0/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}