'Azure B2C Login and then navigate back throws error

We have a net core application that uses an Azure B2C sign in flow.

When the app starts up, the user is directed to the login page and then redirected to Home/Index on successful login.

But, in the browser the user is able to navigate back. When this is attempted the page fails to load a MicrosoftIdentity/Error page.

Is there something I need to set up that I haven't accounted for? We would want the user to stay on the Index page if they attempt to navigate back to the Azure B2C flow.

My StartUp.cs file has this:

   services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme)
                .AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAdB2C"));
            services.AddAuthorization(options =>
            {
                options.FallbackPolicy = options.DefaultPolicy;
            });
            services.AddRazorPages()
                .AddMvcOptions(options => { })
                .AddMicrosoftIdentityUI();


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source