When trying to find a solution for this below question:
MVC Web Api Route, default action does not work
Basically, I am faced with the "multiple actions found" problem. If the routing engine detects more than one action that is consistent with the route, it throws an exception of 500.
For example, in ValuesController there are two actions:
[HttpGet] public IEnumerable<String> Active() { var result = new List<string> { "active1", "active2" }; return result; } public IEnumerable<string> Get() { return new[] { "value1", "value2" }; }
which match the default route:
routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } );
WITH
GET: /api/values
an error will be detected. Several actions were found.
My question is: how can I get around the "multiple actions were found" exception by selecting the specified action (choosing the first consistent action is also good).
Update 1: Update from the tugberk comment, thanks.
Update 2: Update from Mike's comment, it seems the question is not very correct, so I am changing the way I ask without mentioning the routing restriction.
thanks