-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[Mvc] Add support for order in dynamic controller routes #25073
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
Conversation
Could you link to issues this would solve? How many times has this been reported? Overall this sounds like a good change. I'm a little worried about breaking people. Routing changes are hard to debug/communicate in a nice way. I agree that we need a flag to control the new behavior. Ryan added dynamic routing after I worked on routing so I'm not super knowledgeably about it. I'd like to get @rynowak's input on why dynamic routing don't have an order at the moment, and whether there are things we haven't considered. |
{ | ||
internal class OrderedEndpointsSequenceProvider | ||
{ | ||
private object Lock = new object(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readonly
src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreServiceCollectionExtensions.cs
Show resolved
Hide resolved
This was an oversight, and we had low usage of the dynamic routing feature during the few previews it had. We got a trickle of feedback once it went RTM and people started using it. Users in general were confused why it didn't behave like other MVC conventional routing features. |
Hey folks, is there anything else you don't feel is addressed? (- this comment that I don't plan to trigger another build for, I'll fix change it in the future as part of a separate RC2 change) I would like to get this merged today. |
Is there going to be an option or switch to continue using the old behavior or do you feel it is not needed? |
I don’t think we need it, we can add an overload to explicitly set the order if we receive feedback about it. |
Will this be called out as a breaking change and/or mentioned in the 3 -> 5 migration guide? |
Yes, and on the RC1 Blog post |
As a workaround right now I do this:
|
* Order defaults to 1 same as conventional routes * An incremental order is applied to dynamic routes as they are defined.
* Order defaults to 1 same as conventional routes * An incremental order is applied to dynamic routes as they are defined.
* Order defaults to 1 same as conventional routes * An incremental order is applied to dynamic routes as they are defined.
Summary
We want to support order with dynamic endpoints in the same way it is supported for conventionally routed actions.
Motivation
Conventional routes have an order concept that is tied up with the order they are defined in code. That means that a route that is defined earlier during the execution will have
precendence over a route that was defined later. Dynamic routes don't support this functionality and that discrepance is the source of to big problems:
Goals
Non-goals
Scenarios
Risks
Existing applications might experience changes in the matched actions for a given pattern:
We can make this opt-in and enabled in the template by default, with the behavior becomming the default in 6.0.
Interaction with other parts of the framework
Detailed design
We want dynamic routes to behave more like conventional routes and participate in the ordering these routes have:
Drawbacks
Considered alternatives
The alternative is to keep the current behavior, which has the problems we indicated above.