Ambigous route matches
See original GitHub issueDescribe the bug
These two routes lead to an ambiguous match on Toyota-Corolla-vehicles/2
.
[HttpGet("{make}-{query}-vehicles/{makeId:int}")]
[HttpGet("{make}-vehicles/{makeId:int}")]
According to my understanding, they shouldn’t as the two parameters are separated by a -
which is a valid string literal. As per the docs, the routes match non greedily from right to left by comparing literals. the first route has two literals, the second route has only one literal, so I don’t see why it would be ambiguous when Toyota-Corolla-vehicles/2
contains two literals that match the first route in the form of -
and -vehicles
To Reproduce
Add these routes to an action
[HttpGet("{make}-{query}-vehicles/{makeId:int}")]
[HttpGet("{make}-vehicles/{makeId:int}")]
Fire a get in the format
Toyota-Corolla-vehicles/2
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
Xamarin Shell Raise Ambiguous Routes matched Exception
System.ArgumentException: 'Ambiguous routes matched for: ...' This occures when you register your routes in XAML (in the appshell file) and ...
Read more >Failed to Navigate Back, Ambiguous routes matched for.... ...
I am building an Xamarin Forms app for iOS and Android. I registered my routes in AppShell.xaml.cs globally like this: ...
Read more >Ambiguous Matches with React Router - ui.dev
In this post, you'll learn how to handle ambiguous matches with React Router.
Read more >Resolve Ambiguous Controller Error by routes
Now the time is to resolve the common error "multiple matching controllers were found" raised by the routing system when your application ...
Read more >React Router - Ambiguous Matches
Explore this online React Router - Ambiguous Matches sandbox and experiment with it yourself using our interactive online playground.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can configure which one of these you want to be considered first with
Order
. https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/routing?view=aspnetcore-2.2#ordering-attribute-routesI’m not trying to defend the current implementation, the idea you have makes perfectly sense. However, I do think that it would make the route matching code more complex and probably slower (although the slowdown could be limited to figuring out the correct path in case of ambiguity). So let’s wait until someone from the core team joins this conversation.