netcore with azure ad using oidc and the browser back button after sign in causing exceptions
<p>So I have a newly created netcore application linked to my azure active directory account with middleware setup as follows:</p>

<pre><code>       app.UseCookieAuthentication(new CookieAuthenticationOptions()
        {
            AutomaticAuthenticate = true,
            AutomaticChallenge = true                
        });

        app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
        {
            AutomaticAuthenticate = true,
            AutomaticChallenge = true, 
            ClientId = Configuration["Authentication:AzureAd:ClientId"],
            Authority = Configuration["Authentication:AzureAd:AADInstance"] + Configuration["Authentication:AzureAd:TenantId"],
            CallbackPath = Configuration["Authentication:AzureAd:CallbackPath"],                                 
            Events = new OpenIdConnectEvents
            {
                OnAuthenticationFailed = OnAuthenticationFailed,
                OnAuthorizationCodeReceived = OnAuthorizationCodeReceived                                           
            }
        });
</code></pre>

<p>My Callback path a default of "CallbackPath": "/signin-oidc", and my azure sign on url is <a href="http://localhost:20352/" rel="noreferrer">http://localhost:20352/</a>  with a reply url of <a href="http://localhost:20352/signin-oidc" rel="noreferrer">http://localhost:20352/signin-oidc</a></p>

<p>Now I can go through the sign in process fine, but if you hit the browser back button a few times I'm hitting this blow up:</p>

<p>An unhandled exception occurred while processing the request.</p>

<p>Exception: Correlation failed.
Unknown location</p>

<p>AggregateException: Unhandled remote failure. (Correlation failed.)
Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.d__5.MoveNext()</p>

<p>How or where can I catch this exception to handle it accordingly? Or is there something wrong with my middleware setup that is causing this.</p>

<p>The two events above are never hit.</p>

<p>Edit: May be helpful to know the blow up URL from the browser back button is "<a href="http://localhost:20352/signin-oidc" rel="noreferrer">http://localhost:20352/signin-oidc</a>"</p>

<p>Which this obviously doesnt exist as a valid controller / action route</p>