-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Inside area: relative url when no area defined in link #4319
Comments
I believe the behavior you are seeing is correct in both cases. I don't think #4013 has anything to do with it. When you are inside of an area, and try to generate a link outside of the area you need to specify the area explicitly, (the other area you want to generate the link to or null or empty string in case you want to generate a link to an action outside of any area). What is happening in your situation is that you are inside of an Admin area, when you try to generate a link, the area is implicitly defined in the route values (as you hit an action within the area). When the link generation algorithm goes through the list of routes, it tries the first one (the one with the area and it matches it. |
This is an intended change in behavior: aspnet/Announcements#120 |
Yes, it's a consistent behavior. If you don't specify a controller the current controller is used. If you don't specify an area, the current area is used. But I assume that many will stumble over this when they have some sort of menu and introduce an area later on. They will end up with broken links. It's probably a more common scenario than reusing an area-relative link in different areas. Maybe 'asp-area=""' should be added to menu links in samples and templates? |
No plans to make a change in behavior here. |
|
What's your route configuration? |
@Muchiachio
|
Try swapping them around, so that area route would be the first to get evaluated. |
@Muchiachio Thanx |
Please see the announcement post here for explanation #3665 |
I'm not sure if this is intended behavior or I've missed something when I moved from RC1 to RC2 Nightly yesterday:
I have this url inside _Layout.cshtml (under the main Views/Shared/ directory):
With RC1 this link has always been rendered as
Now with RC2 it is rendered as "/" only when I'm on a page in the root directory But as soon as I'm on a page in the /Admin directory (area) it's rendered as:
This behavior can be fixed by adding an empty area:
This also applies to
My routes:
Is this a bug? Is there a global setting? If this is intended then one has to add asp-area="" to links on root pages as soon as an area is added.
The text was updated successfully, but these errors were encountered: