-
Notifications
You must be signed in to change notification settings - Fork 10k
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
LinkGenerator generate wrong links across areas #20489
Comments
@valeriob thanks for contacting us. I believe this is caused by a difference in how endpoint routing treats ambient values. Check https://docs.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-2.2#differences-from-earlier-versions-of-routing for details. @rynowak to confirm, but I think this is expected. |
Ouch, if this is by design it's a very bad news :( So the only way to use netcore3 is to disable EndpointRouting, but what is the path forward ? If you will remove the old behavior before implementing this new feature it will case a lot of pain to a lot of people.
See also Thanks |
The answer from @javiercn is correct. The best thing for now is to revert to the old routing system. We'll be adding a feature in 5 that allows you to have more control over how ambient values behave. |
Hi @rynowak , |
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. |
Yes. That's the plan |
Closing resolved issue. |
Hi,
i've been using this route rules for years (Mvc, AspNetcore <=2.2) now i'm porting a webapp to aspnetcore3.1.
"Area1/{tenant}/{controller=Home}/{action=Index}/{id?}"
"Area2/{tenant}/{controller=Home}/{action=Index}/{id?}"
Generating links for those routes 3.1 it's not working in some scenario :
Url.Action("Index", "Home", new { Area = "Area1", tenant = "t1" }) = "/Area1/t1" Ok
Url.Action("Index", "Home", new { Area = "Area2", tenant = "t1" }) = "/Area2/t2" Ok
if i follow the first link /Area1/t1/Home/Index
Url.Action("Index", "Home", new { Area = "Area1", }) = "/Area1/t1" Ok
Url.Action("Index", "Home", new { Area = "Area2", }) = "/?Area=Area2" Wrong
viceversa if i follow the second link to /Area2/t1/Home/Index
Url.Action("Index", "Home", new { Area = "Area1", }) = "/?Area=Area1" Wrong
Url.Action("Index", "Home", new { Area = "Area2", }) = "/Area2/t1" Ok
This feature is required because to build efficiently a multi-tenant application, you just need to select the tenant once, and it will be passed to the whole application automatically (and have been for many many years).
It looks like that the method GetValues in src\Http\Routing\src\Template\TemplateBinder.cs disables copying AmbientValues if the area is different :( That's very unfortunate.
Attached is the repro, Navigate to link Area1 and Area2 to see the generation failing.
AspNetCore3RoutingBug.zip
The text was updated successfully, but these errors were encountered: