Closed pranavkm closed 5 years ago
cc @rynowak \ @JamesNK
This one seems icky
@JamesNK - it looks like what's happening here is that the longer route isn't getting prioritized. We should look at the precedence of the routes that are decomposed from the conventional route when defaults are in play.
I don't think the longer route should always be prioritized. I think the issue might be in the link generator. If there is a route value for an optional parameter then the link generator should choose prioritize the endpoint with the parameter.
<a asp-route-id="3">Link to item 3</a>
/Home/Index/3
- we want the longer route because of the optional parameter with route value
<a asp-route-action="Index">Link to item index</a>
/
- want the shorter route
<a asp-route-custom="Custom">Link to item custom</a>
/?custom=Custom
- want the shorter route
Title needs tweaking, but here's the gist of it:
Expected: (also what I get with 2.1 routing):
/Home/Index/3
Actual:/?id=3