Open
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I have two routes similar routes where I use route constraints to evade ambiguity:
Route 1:
[HttpGet]
[Route("test/{name}")]
public IActionResult TestByName(string name) { return Ok(); }
Route 2 (with guid):
[HttpGet]
[Route("test/{id:guid}")]
public IActionResult TestById(Guid id) { return Ok(); }
This works as expected. If I now add the required
route constraint (see documentation) to both routes it will throw a Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException
:
Route 1:
[HttpGet]
[Route("test/{name:required}")]
public IActionResult TestByName(string name) { return Ok(); }
Route 2 (with guid):
[HttpGet]
[Route("test/{id:guid:required}")]
public IActionResult TestById(Guid id) { return Ok(); }
Expected Behavior
It should not throw a Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException
.
Steps To Reproduce
See above.
Exceptions (if any)
Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException
.NET Version
8.0.410
Anything else?
No response