-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Inconsistent UrlHelper behavior when two different endpoints have the same action name and use [Admin("url template")]
#16213
Comments
[Admin("url template")]
We triaged this issue and set the milestone according to the priority we think is appropriate (see the docs on how we triage and prioritize issues). This indicates when the core team may start working on it. However, if you'd like to contribute, we'd warmly welcome you to do that anytime. See our guide on contributions here. |
This is a regression. To confirm: does this only happen with This has a chance to be related to #15793. @gvkries do you perhaps have an idea if this is plausible? In any case, the suggested fixes look good, though I'd like to understand why this got broken (or rather, how did it work before). |
This applies to any
The problem is that the route definition in
By accident. I think a recent change (likely the one you linked) revealed this already existing problem. Note that this is an extremely rare edge case. It only happens if you have two controllers in the same module with overlapping action names. Even then only if some have custom routing instead of none or all. |
I can't confirm or disagree that it's caused by #15793. I'm seeing the same behavior before and after this change, but I don't see any other PR that could have caused this behavior change in the specified time period. Maybe I did something wrong when reproducing the issue... |
Describe the bug
I found inconsistent behavior when your module has two different controllers with matching action names (one with default routing and one with custom routing). Manually typing in the expected route works, but if you use
IUrlHelper.Action()
orLinkGenerator
then it generates the path using the/{area}/{controller}/{action}/{id?}
route instead of the expected custom one.We found this in a Lombiq.OSOCE UI test with the following failure report:
To Reproduce
Steps to reproduce the behavior:
ChildRowsController.Get()
TableController.Get()
@Url.Action("Get", "Table", { area = "DataTable", providerName = "foo", queryId = "bar" })
/DataTable/Table/Get?providerName=foo&queryId=bar
instead of/DataTable/foo/bar
.Note that this outcome only happens if the controller with the default path config is resolved first. I think something has changed this resolution order, because I didn't encounter this problem in 1.8.x and it manifested when I upgraded from 2.0.0-preview-18200 to 2.0.0-preview-18226.
Expected behavior
Automatic
IAreaControllerRouteMapper
route maps should only affect their own controller.Suggestion
DefaultAreaControllerRouteMapper
andAdminAreaControllerRouteMapper
should substitute{controller}
too, not just{action}
. See this example.Screenshots
This shows the
routes.DataSources.First()._routes
private field, which contains the routes registered when using theroutes.MapAreaControllerRoute()
extension method. As you can see these overly generic default routes are taking up priority.The text was updated successfully, but these errors were encountered: