Skip to content

Blazor Router.OnNavigateAsync accept cancel or NavigationManager.ChangingHandler can handle first request #63536

@cyuz

Description

@cyuz

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

I'm using Blazor 8 Interactive Serve to complete a system.

I want redirect user to another page, if some condition meets.

  • But Router.OnNavigateAsync cannot cancel previous navigation context, user sometimes see a flash.
  • NavigationManager.ChangingHandler can cancel, but it cannot handle first navigation.

current workaround is a mix of

  1. Set a mask flag to hide display
  2. Try redirect in OnInitializedAsync, or clear flag
  3. NavigationManager.ChaningHandler
  4. Clear flag in OnLocationChanged

Describe the solution you'd like

Expect a one-shot centralize solution

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions