Azure AD B2C Sign-Out Redirection to Root Instead of /MicrosoftIdentity/Account/SignedOut after Upgrading to .NET 8

I recently upgraded my Blazor Server project from .NET 7 to .NET 8 and am encountering an issue with Azure AD B2C sign-out redirection. In .NET 7, users were correctly redirected to /MicrosoftIdentity/Account/SignedOut upon signing out. Post-upgrade, they are being redirected to the root URL (“/”) instead.

Here’s what I’ve checked and implemented:

The post-logout redirect URI in Azure AD B2C settings is still set to /MicrosoftIdentity/Account/SignedOut.
The OpenID Connect middleware configuration in my app is set up with the SignedOutCallbackPath (code snippet below).
In .NET 7, I used app.UseRewriter to redirect from /MicrosoftIdentity/Account/SignedOut to a custom sign-out page. This setup now seems to be causing issues in .NET 8, as users landing on the website are being redirected from the root, which is not the intended behavior.

I suspect this issue might be related to changes in .NET 8 or how the middleware handles sign-out redirects.

app.UseRewriter(
new RewriteOptions().Add(
    context =>
    {
        if (context.HttpContext.Request.Path == "/MicrosoftIdentity/Account/SignedOut")
        {
            context.HttpContext.Response.Redirect("/counter");
        }
    }

));

  • Please post the code as a text, not a screenshot.

    – 

  • I have edited the post.

    – 

  • Not a screenshot, just a text only.

    – 

  • 1

    Removed screenshot

    – 

Leave a Comment