An overlapping route template matches at least one URL also matched by another template. That ambiguity can prevent routing from selecting a single endpoint. section 6.3.3
A URL matched twice
Suppose two endpoints use "/{number}/{name}" and "/{product}/{id}". The URL "/shoes/123" matches both, so the routing middleware throws an exception. Adding an integer constraint to the first template, "/{number:int}/{name}", removes that particular match, but "/123/shoes" still matches both. Prefer distinct route designs over relying on constraints to untangle ambiguous templates. section 6.3.3
Watch for overlapping templates when using Razor Pages conventions:
- Pages/ToDo/Index.cshtml creates both "/ToDo" and "/ToDo/Index" routes. section 14.3
- Adding Pages/ToDo.cshtml beside Pages/ToDo/Index.cshtml creates a collision at "/ToDo". section 14.3
- Avoid unnecessary absolute paths, literal additions, and extra AddPageRoute() templates when they can duplicate existing conventions. section 14.6
Figure 14.4 If multiple Razor Pages are registered with overlapping route templates, you’ll get an exception at runtime when the router can’t work out which one to select.
Use the figure to see why multiple Razor Pages with overlapping templates fail at runtime when the router cannot choose one. section 14.6
