How can I logout (Identity) in code in a Blazor server app

David Thielen 966 Reputation points

Hi all;

In my code I handle a DbUpdateConcurrencyException and for the case of updating a user's account, and the user no longer exists, I want to log them out - as they are no longer a valid user.

Granted, not a biggie because this should be rare and any page they try to go to will not accept them as they no longer have a claim. But its cleaner to log them out.

I can't use the SignInManager in Blazor. It requires a POST to LogOut.cshtml. So, what's my options?

thanks - dave

A set of technologies in the .NET Framework for building web applications and XML web services.
3,159 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce ( 36,261 Reputation points

    just create a logout razor page that calls:


    the via javascript interop redirect to the page