I am having problems with my MVC Routes.
I am trying to get to the following url ... "http://localhost/api/Countries"
I have defined the following routes in the following order ...
RouteTable.Routes.MapHttpRoute(
name: "Continents",
routeTemplate: "api/countries/Continents",
defaults: new { controller = "countries", Action="Continents" }
);
RouteTable.Routes.MapHttpRoute(
name: "CountryRegions",
routeTemplate: "api/countries/Regions",
defaults: new { controller = "countries", Action = "CountryRegions" }
);
RouteTable.Routes.MapHttpRoute(
name: "CountryByCodeApi",
routeTemplate: "api/{controller}/{countryCode}",
defaults: new { controller="countries", countryCode = System.Web.Http.RouteParameter.Optional }
);
Whenever I go to the desired URL I am getting the error "Multiple actions were found that match the request". This would make sense if the third segment of the routeTemplate property was optional but it was my understanding that by NOT enclosing it in braces that it made it a required segment in the target URL. Obviously "http://localhost/api/countries" does not include "Continents" or "Regions" so why would they be identified as matching the request.
Ya' know. These routes SEEM like a simple enough thing but when you get down to it it's a cryptic as RegEx's !!!
Any thoughts?