Fix “Correlation Failed” in ASP.NET Core OpenID Connect

Quick answer. Verify that the short-lived correlation cookie survives the redirect and is sent back on the configured callback URL.

Applies to. ASP.NET Core

Authentication and stateTrace challenge and callbackFind missing correlation cookieRetest redirection
Trace challenge and callback → Find missing correlation cookie → Retest redirection

What does the error look like?

Sign-in succeeds at the identity provider, but the callback fails when the handler cannot correlate it with the original challenge.

How do you diagnose the cause?

Compare challenge Set-Cookie and callback request cookies in DevTools. Look for hostname or scheme changes, reverse proxy forwarded-header trust, callback-path mismatch, SameSite settings differing from handler defaults, and expired or stale sign-in tabs. Keep state and correlation protection enabled.

Worked example

Use the relevant portion below in a development or staging environment. Match the existing application’s packages, settings, and environment before applying the change.

C#
// Put configured, trusted forwarded headers ahead of auth middleware.
app.UseForwardedHeaders();
app.UseAuthentication();
app.UseAuthorization();

In Blogger preview, you can select the snippet and copy it directly.

How do you verify the fix?

CheckExpected behavior
Retest redirectionA new login completes through the intended public HTTPS origin.
Repeat with the original failing input or setupThe relevant error is reproducible under the old conditions and resolved under the corrected conditions

These are expected results to validate in your environment.

What should you check first if the error returns?

Verify that the short-lived correlation cookie survives the redirect and is sent back on the configured callback URL.

Official documentation · ASP.NET tutorials

Comments