Open Emma37 opened 4 years ago
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Hi @Emma37. Just wanted to share some context here. The current behavior is by-design. However we did receive similar feedback in the past. We plan to revisit this issue when we will be planning for .NET 6 and see whether there is something we can do to help in this space.
I also think that is not natural this behavior, and it creates some problem creating internal portable references...
This feature would help a lot with content generated from markdown. Almost all markdown parsers use relative links for footnote and header links.
Any news on this? I'm on .NET 7.0 and NavigationManager.NavigateTo also displays this unnatural behaviour, afaik only URLs that start with a forward slash (/) should be treated as absolute
Same issue with SSR Blazor
When trying to create components that use relative URLs in the href I am always directed back to the base url rather than relatively, e.g.
base-url/page
instead ofbase-url/other/things/page
I've tried
href="page"
,href="./page"
and"href="~/page"
as I saw these suggested but the only thing I've found that works is to use a Navigation Manger to directly access the current URL and then add to this - but this feels over the top?I originally thought it was because I was using a NavLink component but I am also getting it with simple anchor tags. So I think it is incorrect behaviour.
Additional context/further feature request
The context where this has come up is trying the build a subnav component that we can re-use across different subsites/contexts. This is why using an absolute path isn't an option.
The site has the structure:
base-url/sub-site/page/sub-page
So the subnavigation needs to be able to handle any previous url
base-url/sub-site-A/page-B/
,base-url/subsite-C/page-D
etc. but it provides all the same suffixes across these various prefixes.Simply capturing the current URL and adding to it then caused issues like
base-url/sub-site/page/sub-page/sub-page
and trying to remove parts of the URL might work but gets complicated when I consider more complex routes likebase-url/sub-site/page/sub-page/sub-sub-page/...
so that's not extensible eitherSo far I have made a workaround by passing the required relative base URL to the subnav component through a cascading parameter, i.e.
relativeBase = “base-url/sub-site/page/”
, then basing all hrefs in the subnav off of this new base.However this all seems like I am missing something or that this is harder than it needs to be. Could there potentially be a SubNavLink component which could handle this kind of functionality: matching on some portion of the URL or have some ability to pattern match on the URL?
Thanks!