Skip to content

[Blazor] execute check at high level to redirect to another page #24054

@julienGrd

Description

@julienGrd

hello guys, i have some trouble with my blazor webassembly webapp when the user decide to refresh the page (with f5 for example).

I can't maintain a stable state concerning my data so if its happen i prefer disconnect him and and redirect him to the login page.

im able to suscribe to the onload js event and call method of one to my component to disconnect the user, it work. but in this method, if i try to redirect to the login page with the NavigationManager its not work (it stay on the current page, no redirection)

I try another way, in my layout on the OnInitialized method i check if my user is not connected and if im not on the login page, if its the case i redirect to the login page. It works, but the problem is the current page will run her lifecycle with inconsistend data so it will sometimes crash. So there is a way to do that at another level to be sure the current page will not be loaded ?

I wait for yours suggestions, don't hesitate if you have better idea to achieve what i want !

thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions