-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Routing order with path match and a MapDynamicControllerRoute #21083
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
Comments
@rynowak . |
Thanks for contacting us. |
This seems like a reasonable expectation from the outside, but it's not how routing really works. Things like It is done this way because:
The case that we're optimizing for here is where there's a complex policy that comes after your
Other policies includes things like:
Since dynamic policies can change the set of endpoints being considered, they need to run before those things, so that they can see the endpoints returned from your policy as well as others and consider them together. We could consider adding features to Since you're interested in avoiding your logic running - what kind of criteria would you base that on?
|
Rynowak, thanks for the very detailed explanation, this makes more sense now. Yes I'd like to avoid running logic if there is a match already. I think I'm going to approach this different with this new understanding. UseRouting() to match stuff like /, /about /contact us, and then another middleware after routing that checks if GetEndpoint() is null and if so does the custom matching and then .SetEndpoint - just need to figure out how to get/create the relevant Endpoint - any pointers? thanks |
Thank you for contacting us. Due to a lack of activity on this discussion issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue. This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue! |
I beleive this could possibly be related to #16579. We're using ASP.Net Core 3.1 LTS with MVC Controllers and have set of static routes plus a whole lot of dynamic routes for categories, products and other slug styles (driven by an inmemory cache of some database view).. milliseconds are important on our GET pipeline so we noticed something odd but not breaking as the correct route is eventually resolved.
If I wire up a simple scenario of match homepage, and a DynamicRouteValueTransformer that has a big cache from a database to decide which controller/action to select, then I expect only the match for the homepage to be hit when I GET ?, but instead it goes through TransformAsync on RouteResolver too (with no routevalues set) - whilst it works it seems inefficient and adds several milliseconds to our request processing.
Scenario: GET /
Expected: TransformAsync on RouteResolve not to be called.
Actual: TransformAsync on RouteResolve is needlessly called.
The text was updated successfully, but these errors were encountered: