❔ Blazor WebAssembly: How to dynamically hide a layout component after logging out
Question:
I have a Blazor WebAssembly application where I'm using the MudBlazor library to create a layout that includes a navigation bar (MudAppBar). I want to dynamically hide this navigation bar after a user logs out of the application.
Here's the relevant part of my layout:
I'm triggering the logout process using the following code:
Inside my Logout method, I'm using NotifyAuthenticationStateChanged to reset the authentication state and set it to an empty ClaimsPrincipal.
However, after navigating to the login page (/login), the navigation bar (MudAppBar) is still visible. It seems that the main layout is rendered when _navigationManager.NavigateTo("/login") is invoked.
How can I ensure that the navigation bar is hidden after a user logs out and navigates to the login page? Is there a way to dynamically update the layout based on the authentication state without requiring a hard refresh of the page?
I appreciate any insights or suggestions to resolve this issue.
Here is my custom AuthenticationStateProvider - how i user NotifyAuthenticationStateChanged - -> check the Logout() method.
https://paste.mod.gg/kvvtgasbzsxo/0
BlazeBin - kvvtgasbzsxo
A tool for sharing your source code with the world!
1 Reply
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.