Abdulsalam Elsharif
Abdulsalam Elsharif

Reputation: 5111

Redirect unauthorized user to another page component

In Blazor WASM project I'm using ASP.NET Identity, I want to redirect unauthorized user that do not have the role that allow him access to some pages, I protect the page using:

@attribute [Authorize(Roles = "Admin")]

It works, Now when the user try to access to the page, He got a blank page, What I want to do is to redirect him to another component page, How can I do that with Authorize attribute ?

I tried to redirect the user in OnInitializedAsync but it seems the page not loaded to access to this method!

Any help

Upvotes: 1

Views: 902

Answers (0)

Related Questions