We currently take a union of the route values for action selection. This approach doesn't always work; sometimes it results in selecting the wrong action.
I'm guessing the right approach is for the uber-route to produce no values (except the sub-route) and for action selection to look at separate route values per action descriptor.
Also note that optional values that haven't been specified need to be removed both before this action selection logic as well as when elevating route data. (See RemoveOptionalParameters in HttpRoutingDispatcher).
Repro:
[RoutePrefix("tokens")]
public class TokensController : ApiController
{
[Route("{id:int}")]
public string GetById(int id)
{
return "id" + id;
}
[Route("{name}")]
public string GetByName(string name)
{
return "name" + name;
}
[Route("{id:int}")]
public string GetDetails(int id, string name)
{
return "id" + id + "name" + name;
}
}
GET of tokens/12 produces id12name instead of id12.
I'm guessing the right approach is for the uber-route to produce no values (except the sub-route) and for action selection to look at separate route values per action descriptor.
Also note that optional values that haven't been specified need to be removed both before this action selection logic as well as when elevating route data. (See RemoveOptionalParameters in HttpRoutingDispatcher).
Repro:
[RoutePrefix("tokens")]
public class TokensController : ApiController
{
[Route("{id:int}")]
public string GetById(int id)
{
return "id" + id;
}
[Route("{name}")]
public string GetByName(string name)
{
return "name" + name;
}
[Route("{id:int}")]
public string GetDetails(int id, string name)
{
return "id" + id + "name" + name;
}
}
GET of tokens/12 produces id12name instead of id12.