Blazor WASM Logout and .Net 7.0


In .NET 6.0 there seems to be some sort of issue between blazor WASM and Auth0 when it comes to logging out. Apparently, it should be possible to do this:

await SignOutManager.SetSignOutState();

I never got this to work reliably and had to resort to a bit of a hack:

await SignOutManager.SetSignOutState();
var authority = Config.GetSection(“Auth0”).GetSection(“Authority”).Value;
var clientid = Config.GetSection(“Auth0”).GetSection(“ClientId”).Value;
var url = Config.GetSection(“WebsiteUrl”).Value;
var signout = $“{authority}/v2/logout?client_id={clientid}&returnTo={url}authentication/logout”;

The above seems to work.

I just upgrade to .NET 7.0 and now neither of the above work and it appears to be impossible to logout.

I’m probably a bit early with .NET 7.0. Does anyone have any ideas?

Thank you

@Ditchford did you find a solution to this problem? I am working on a .NET 7 upgrade and am having similar issues with logout. To summarize my issue, when I click logout, it calls the v2/logout, and then redirects back to the application, but the session is still active. I have to click logout again, and then it works.

Hey @dahln. I sort of guessed and hacked a bit. I’m still not sure if this is the way to do it, but it seems to work:

  await JSRuntime.InvokeVoidAsync("sessionStorage.clear");

Hope this helps.


Thanks for sharing that, I’ll mark it as a temporary solution but maybe @andrea.chiarelli will be able to help on that front :pray:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.