Skip to content

Trigger LocationChanging callbacks on enhanced navigation #48766

@SteveSandersonMS

Description

@SteveSandersonMS

Location changing handlers may not always be invoked on enhanced navigation. For example, when no interactive router is present, interactive components cannot intercept user-initiated navigations.

From @MackinnonBuck:

"When an enhanced navigation occurs, LocationChanged event handlers registered in interactive runtimes (i.e., Blazor Server/WebAssembly) get invoked. However, location changing handlers may or may not intercept enhanced navigations, so it's important that app logic not rely on location changing handlers being invoked reliably. For example, the user might switch to another page before an interactive runtime becomes available. In .NET 8, if server-side routing and enhanced navigation are enabled, location changing handlers will only get invoked for programmatic navigations initiated from an interactive runtime. In future .NET versions, more types of navigations (e.g., link clicks) may also invoke location changing handlers".

A more detailed analysis of when location changing handlers get invoked can be found here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions