I am trying to develop an app using Blazor WebAssembly and I am wondering about how I can protect my whole application if the user is not authenticated. The behavior I would implement is:
- If an anonymous user asks for any page, then he will be redirected to the login page
Better
- a user must be authenticated for using this app
At the moment I've implemented this behavior applying the [Authorize]
attribute to every page, but I would like to centralize it.
I've achieved this goal on Blazor Server Side applying the [Authorize]
attribute inside the _host.razor
component.
Is there a solution even for Blazor Client Side?