Blazor Web App (.NET 8) - Logout functionality with IdentityCore
What's the best way to implement log out functionality? Looks like I can't use
signInManager.SignOutAsync()
on an InteractiveServer application4 Replies
I use this
a simple link to
/logout
will trigger the logout, and the auth infra will redirect back to the login pageI see you're using HttpContext there, but isn't that unavailable when using interactive server?
yes. that's why i'm using a minimal apis endpoint here. to force a page-cycle which will have httpcontext.
just because the source page is interactive server doesn't mean all pages are interactive server
if you have a link from a blazor page to something else, it'll force a page load like any other
I see - thanks for the tip, I'll have a go at implementing it and see if I can get it working
That worked, thank you. Using:
and then navigating to the Logout route while forcing a refresh with:
NavigationManager.NavigateTo("/Logout", true);
Thanks for the help!