I have a Blazor WASM having 2 layouts:
- MainLayout
- LoginLayout
My main Index file has an Authorized attribute
@page "/"
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Components.WebAssembly.Authentication
@attribute [Authorize]
When its not authorized is being redirected to "auth/login" which uses a different layout (LoginLayout) where I have a simple login page.
The problem im facing is that when I access the application I can see for a second the MainLayout (header, navigation left menu, footer) and then I see my blank screen with my login.
This means that because Index is the main route and uses MainLayout, it takes about 1 second to validate and do the redirect to my Login page and thats why the Layout issue.
Is there a way to do the redirect before the
MainLayoutis rendered in the page? Or a way to not show the Layout HTML if the user is not authenticated?