Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Route constraints invoked for paths which do not use the route constraint #57572

Closed
1 task done
onionhammer opened this issue Aug 28, 2024 · 3 comments
Closed
1 task done
Labels
area-routing ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved

Comments

@onionhammer
Copy link

onionhammer commented Aug 28, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Using a {parameter} in one route and a {*catchall} in another route causes a RouteHandlers to be invoked unrelated requests

Example:

/tiles/{**path} 
/{partner:my_route_constraint}/{form}.js

the my_route_constraint will be invoked with "tiles" as the routeKey value of partner even though the path is not using that constraint, and is more specific (starts with /tiles/) for certain requests

example:

GET /tiles/one_segment <-- this hits the route constraint
GET /tiles/one_segment/two_second <-- this does not hit the route constraint

Expected Behavior

If you specify a prefixed route, it should not hit a route constraint?

Steps To Reproduce

Here is a repo that reproduces the issue:

https://github.com/onionhammer/repro-routing-issue/blob/master/Program.cs

Reference test.http for example requests

Exceptions (if any)

No response

.NET Version

8.0.401

Anything else?

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Aug 28, 2024
@javiercn javiercn added area-routing and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Sep 18, 2024
@javiercn
Copy link
Member

@onionhammer thanks for contacting us.

This is by design. Routing evaluates the current path against all potential matches as a first step and then applies matcher policies and ordering to get a final result.
/tiles/{**path} might not match because it has an HTTP POST constraint and, in that case, /tiles/sample.js will still match and can't be discarded.

@javiercn javiercn added question ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. labels Sep 18, 2024
@onionhammer
Copy link
Author

Why was the choice made to not just route to a more specific path?

Copy link
Contributor

This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.

See our Issue Management Policies for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-routing ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved
Projects
None yet
Development

No branches or pull requests

2 participants