Method OnNavigationStarting
OnNavigationStarting(NavigationType, NavigatorRoute)
Called synchronously at the start of a navigation, before any view model lifecycle methods are invoked and before any awaits occur. Implementations should perform any synchronous work required at the start of a navigation, such as updating browser history state on WebAssembly platforms (which must happen synchronously while user activation is still valid).
Declaration
protected virtual object? OnNavigationStarting(NavigationType navigationType, NavigatorRoute targetRoute)
Parameters
| Type | Name | Description |
|---|---|---|
| NavigationType | navigationType | The type of navigation that is starting. |
| NavigatorRoute | targetRoute | The route that the navigation is targeting. Note that this may differ from the final route if a redirect occurs during navigation, in which case a nested navigation will be started for the redirect target. |
Returns
| Type | Description |
|---|---|
| object | An optional state object that will be passed back to OnNavigationCompleted(NavigationType, NavigatorRoute, NavigationResult, object?) when the navigation completes. This is useful for implementations that need to track per-navigation state without having to use instance fields (which would be clobbered by nested redirect navigations). |
Remarks
If a redirect occurs during navigation, this method will be called again for the redirect target as part of the nested navigation. The IsRedirecting property can be used to detect this case.