Replies: 1 comment
-
|
I ran into the same issue recently and ended up solving it by replacing NavigationManager rather than trying to replace Router or intercept everything at the browser level. That let me keep the real browser path fixed at the app base path and move the Blazor route into the URL fragment instead, so refresh/deep-link scenarios work even when the host can’t rewrite arbitrary paths back to index.html. I’ve packaged that approach here in case it helps anyone else hitting the same limitation: Blazor.HashRouting on NuGet - https://www.nuget.org/packages/Blazor.HashRouting |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
After see #6175, I want to implement my own solution. However, what I thought would be a fun side project turned into frustration. My plan was to simply transform the URL path into hash at the browser end so we can reuse everything else of the current routing system.
Router. Nope most of the things areinternalorprivateand there is not even a way to wrap it due to all the injection. Wrapping: not possible, copying the whole code: not possible due to multipleinternalclasses as well.globalThis.location(href) andglobalThis.history(forpushStateandreplaceState). I failed becauselocationcannot be modified in any way:Proxy,definePropertyor even straight up replacing thewindowobject (strangely enough it wasn't a problem withhistory). Then I go to a milder option of replacingBlazor._internal.navigationManagerbut still wasn't successful because beside the obvious functions (that barely even called), a few of them can't be modified at all.So, IMO, for something as important as Routing, it's so hard to intercept and customize. I had a similar frustration before when trying to modify the
IJSRuntimeobject (though in the end I barely made it through by modifying the whole DI thing and wrap it). I wish they either open up more point of customization or stop hiding so many important classes.What do you think? Do you have any suggestion where I may be able to continue with this? Thanks.
Beta Was this translation helpful? Give feedback.
All reactions