Browser history can be accessed in Blazor using the window’s popstate event, which is fired when the user navigates the session history. We use the history API to get the history changes in the browser, and we can manually move to a specific page using back(), forward(), go().
When routing takes place in the application or browser, you can use the following code to store the current location:
Window.history.pushState({ prevUrl: window.location.href }, null, newpath) |
To retrieve the previous URL, use the following code in your new route:
Window.history.state.prevUrl |
Refer to this link for more information about the popstate event.
Refer to this link for more information about the history API.
Share with