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
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.
// 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?
| Check | Expected behavior |
|---|---|
| Retest redirection | A new login completes through the intended public HTTPS origin. |
| Repeat with the original failing input or setup | The 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.
Comments
Post a Comment