1

Closed

Attribute routing value union is problematic

description

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.
Closed Sep 4, 2013 at 8:58 PM by kichalla
Verified.

comments

davidmatson wrote Jan 24 at 6:38 PM

Fixed in changeset 2253a717171aebb053927551c5905a505e7573f9