-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
This was requested by @zbecknell following a different comment:
We're coming up to about a year of developing a Blazor app for a new project with a small team, and it's amazing! Thanks to this, we've encountered a good number of scenarios with a variety of challenges. As an example scenario I have a page with the following route:
/account/{accountId}
When on this page, there is the possibility of navigating from say /account/1 to /account/2 via NavigationManager -- this causes OnParametersSet to trigger, but NOT OnInitialized since the page is already loaded, so we need to rely on OnParametersSet to know when to reload our page state for a different account.
We want to assume that OnParametersSet triggering really means that a page parameter has changed, otherwise we'd need to keep track of each parameter's before and after state and manually allow the data to reload.
This is why I want to bypass the LocationChanged event, BUT I still need my NavigationManager.Uri to stay synced with the actual browser's URL, otherwise I'd need to use JsInterop to retrieve the actual URL, which necessarily needs to be async, which introduces yet more timing complexity. (I can't use the sync JsInterop because I dual-host client/server Blazor.)
I'm already using interop for my current solution, but it has a bug due to the Uri not being in sync. I'm probably going to solve this in the interim by keeping track of my own Uri variable instead of relying on NavigationManager.
All that being said, this is why another proposal of mine was just letting me set the Uri for NavigationManager programmatically to manually keep it in sync, but I get why that would be likely to cause confusion, and thus isn't an acceptable solution.