Skip to content
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

Blazor - Allow hashed routing #6175

Open
LukeTOBrien opened this issue Dec 29, 2018 · 19 comments
Open

Blazor - Allow hashed routing #6175

LukeTOBrien opened this issue Dec 29, 2018 · 19 comments
Labels
affected-very-few This issue impacts very few customers area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-builtin-components Features related to the built in components we ship or could ship in the future Pillar: Complete Blazor Web Priority:2 Work that is important, but not critical for the release severity-minor This label is used by an internal tool
Milestone

Comments

@LukeTOBrien
Copy link

LukeTOBrien commented Dec 29, 2018

Hello there.

I have just been reading this in-depth guide.
In the section Client Routing the article states:

One caveat with routing is that it uses normal URLs and there is no hashed mode.
That is, a @page "/counter" will be accessible at the /counter URL and there is no option to use #/counter.
While this is something desirable in most cases, it means that the server hosting the Blazor app should be configured to redirect all URLs that don’t match a static file to the index.html file, which will then bootstrap the application in the browser and will ultimately perform the navigation.

I have recently created a Angular app that required hashed routes, as it was purely client-side, the server was a MVC controller and I did not want my client making requests to the server... only for the server to redirect to index.html... plus I found that the server had trouble deciding between component and API routes.

I think hashed routes are a very important feature, and for my previous project they where a necessity.

Hope this is added in future.

@Eilon Eilon added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jan 2, 2019
@danroth27 danroth27 added the area-blazor Includes: Blazor, Razor Components label Feb 6, 2019
@mkArtakMSFT mkArtakMSFT added this to the Backlog milestone Apr 8, 2019
@mkArtakMSFT mkArtakMSFT removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels May 9, 2019
@mkArtakMSFT mkArtakMSFT added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Jan 10, 2020
@ndc
Copy link

ndc commented May 24, 2020

I suppose we don't have to worry about base path with hash navigation, which is a plus.

@DenisNP
Copy link

DenisNP commented Jun 30, 2020

Any chances this will be implemented? For example: I make apps which should be opened in iframe, so there is only way to use hash navigation.

Also, I suppose, hash navigation is the only option for hybrid mobile apps (cordova/capacitor).

@SteveSandersonMS SteveSandersonMS added affected-very-few This issue impacts very few customers severity-minor This label is used by an internal tool labels Oct 6, 2020 — with ASP.NET Core Issue Ranking
@michielpost
Copy link
Contributor

I would also like to have the option to configure hash navigation. I'm deploying my Blazor WebAssembly to a server I don't have any control over, so I can't configure a catch all route to the index.html.

@Swimburger
Copy link

I'm trying to use Blazor WASM inside a Chrome extension and I can't reroute all requests to index.html. Hash routing would be helpful.

@jonrmorgan99
Copy link

I'm migrating an old Asp.Net Web Forms site to Blazor. It's littered with hash routings for scrolling in-page. Changing href="#install" to "thispage#install" doesn't work. Implementing hash routing before net6 would be really welcome.

@javiercn javiercn added the feature-blazor-builtin-components Features related to the built in components we ship or could ship in the future label Apr 19, 2021
@bruceharrison1984
Copy link

We ran into this same issue hosting a static Blazor SPA on a CDN. All status code have to redirect back to index.html. Seems strange since hashed routing is pretty standard at this point for SPAs.

@Mercurial
Copy link

Is there a way to do this today?

@holtalanm
Copy link

There are numerous reasons for needing the ability to use hash routing. Is there a solid reason why this isn't implemented? Honestly, kind of expected Blazor to support this out of the box.

@bachratyg
Copy link

Hash routing would solve #18986 as well.

@rajsite
Copy link

rajsite commented Mar 25, 2022

We'd like to host blazor wasm apps on GitHub Pages (not at the root) and it looks like the lack of hash based routing makes that difficult.

@Swimburger
Copy link

@rajsite I would recommend using the default routing, and only use hash routing if you can't avoid it. I guess we can't use hash routing atm anyway.
You can deploy Blazor WASM to GitHub Pages without hash routing: https://swimburger.net/blog/dotnet/how-to-deploy-aspnet-blazor-webassembly-to-github-pages

@rajsite
Copy link

rajsite commented Mar 25, 2022

@rajsite I would recommend using the default routing, and only use hash routing if you can't avoid it. I guess we can't use hash routing atm anyway. You can deploy Blazor WASM to GitHub Pages without hash routing: https://swimburger.net/blog/dotnet/how-to-deploy-aspnet-blazor-webassembly-to-github-pages

There are some useful workarounds in there, more-so if the blazor application is the only one on the pages site at root (which is not our scenario). Even if we did have a single blazor app at root, serving the 404 as the application is not ideal (like the blog hints at). All to say lack of hash based routing makes using GitHub Pages difficult (need workarounds and undesired trade-offs).

@ordinaryorange
Copy link

I think this is a necessity too. Modern browsers know about the #, other SPA frameworks use it and it gives SPA developers more capacity to avoid unnecessary round trips to the server.

I also hit an issue where the documented redirection URL from Azure AD authentication breaks when a Blazor WASM only SPA is hosted from a static website (Such as Azure storage static website)
While I've a workaround, if a # could be configured in the redirect URL and Blazor handled #'s, then that would solve that problem too.

@tzographos
Copy link

Is there any progress on this?

@mkArtakMSFT mkArtakMSFT added this to the .NET 8 Planning milestone Sep 28, 2022
@ghost
Copy link

ghost commented Sep 28, 2022

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@ghost
Copy link

ghost commented Jun 29, 2023

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.

@ricardok1
Copy link

This means for net9?!?

@ghost
Copy link

ghost commented Dec 19, 2023

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.

@xcaptain
Copy link

xcaptain commented May 8, 2024

What's the progress? I'm planning to deploy my website to ipfs, need to have this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected-very-few This issue impacts very few customers area-blazor Includes: Blazor, Razor Components enhancement This issue represents an ask for new feature or an enhancement to an existing one feature-blazor-builtin-components Features related to the built in components we ship or could ship in the future Pillar: Complete Blazor Web Priority:2 Work that is important, but not critical for the release severity-minor This label is used by an internal tool
Projects
None yet
Development

No branches or pull requests