Azure B2C: User not logged out after logoutURI

Hannes Dendoncker 20 Reputation points
2024-11-29T09:53:38.1933333+00:00

Hi,

I've configured a B2C tenant and built a .NET MVC app to use it as a login. Now, I'm trying add an option for the user to sign out, so a different account can be selected. Signing out of the app is easy, I just do

await HttpContext.SignOutAsync("Cookies");
await HttpContext.SignOutAsync("OpenIDConnect");  

but the issue is, when I log back in, I never get prompted to select an account, it defaults to the previous account, that still logged in with the B2C tenant. So next step, also log out of the B2C when the logout is called. I tried to do this by calling

logoutUrl = $"{azureAdB2COptions["Instance"]}{azureAdB2COptions["Domain"]}/b2c_1a_signup_signin/oauth2/v2.0/logout?" + $"post_logout_redirect_uri={Uri.EscapeDataString("https://localhost:7043/")}";

This runs fine, no errors, but the issue I had still persists! The user never gets logged out! This conflicts with all the information I find online. Any idea what causes this, the user is never logged out of the B2C tenant, or is instantly logged back in. I added this in my Program.cs

options.Prompt = "select_account";

but no luck. Any help is appreciated. Thank you.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,964 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,422 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.