Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Created Unassigned: '{action}' variable on controller-route not considered during action matching [1239]

$
0
0
For the following controller, a request like "/api/customers/GetAllCustomers1" is resulting in "Multiple actions found..." error

__Attached__ a standalone katana repro.

```
[Route("api/customers/{action}")]
public class CustomersController : ApiController
{
public string GetAllCustomers1()
{
return "GetAllCustomers1";
}

public string GetAllCustomers2()
{
return "GetAllCustomers2";
}
}

```

__Reason__:
We need to following similar approach like convention routing does for '{action}' variable. Interesting piece of code:

ApiControllerActionSelector source:
```
if (routeData.Values.TryGetValue(RouteKeys.ActionKey, out actionName))
{
// We have an explicit {action} value, do traditional binding. Just lookup by actionName
ReflectedHttpActionDescriptor[] actionsFoundByName = _standardActionNameMapping[actionName].ToArray();

// Throws HttpResponseException with NotFound status because no action matches the Name
if (actionsFoundByName.Length == 0)
{
throw new HttpResponseException(controllerContext.Request.CreateErrorResponse(
HttpStatusCode.NotFound,
Error.Format(SRResources.ResourceNotFound, controllerContext.Request.RequestUri),
Error.Format(SRResources.ApiControllerActionSelector_ActionNameNotFound, _controllerDescriptor.ControllerName, actionName)));
}
```

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>