question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unclear how to catch "System.Exception: Correlation failed." and prevent HTTP 500

See original GitHub issue

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

This appears to be an issue with ASP.NET RemoteAuthenticationHandler. When this exception is thrown due to this line in the OpenIdConnectHandler (“Correlation failed.”), we end up returning an HTTP 500 error because that exception is not caught. It’s not obvious how it can be caught.

Expected Behavior

We expect there to be some way to catch that exception so we can redirect to an error page rather than returning an HTTP 500. We’re interested in what the recommended ASP.NET approach is to catching and handling this particular exception.

Steps To Reproduce

Unclear, we suspect our users are hitting the back/forward button on our login page or otherwise allowing the cookie to time out, then trying to log in which causes the “Correlation failed.” exception.

Exceptions (if any)

System.Exception: An error was encountered while handling the remote login.
---> System.Exception: Correlation failed.
--- End of inner exception stack trace ---
at Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.HandleRequestAsync()
at Duende.IdentityServer.Hosting.FederatedSignOut.AuthenticationRequestHandlerWrapper.HandleRequestAsync() in /_/src/IdentityServer/Hosting/FederatedSignOut/AuthenticationRequestHandlerWrapper.cs:line 52
at Duende.IdentityServer.Hosting.DynamicProviders.DynamicSchemeAuthenticationMiddleware.Invoke(HttpContext context) in /_/src/IdentityServer/Hosting/DynamicProviders/DynamicSchemes/DynamicSchemeAuthenticationMiddleware.cs:line 48
at Duende.IdentityServer.Hosting.BaseUrlMiddleware.Invoke(HttpContext context) in /_/src/IdentityServer/Hosting/BaseUrlMiddleware.cs:line 28
at <... our code from here on>

.NET Version

6.0.403

Anything else?

Issue Analytics

  • State:open
  • Created 9 months ago
  • Reactions:6
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
changhuixucommented, Mar 7, 2023

It’s an annoying exception that we don’t have a good way to catch it in our middleware. Many thanks to those who are working on it.

2reactions
msftbot[bot]commented, Jan 3, 2023

Thanks for contacting us.

We’re moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it’s very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Correlation failed in net.core / asp.net identity / openid ...
To verify, navigate to chrome://flags/ and change "Cookies without SameSite must be secure" to "Disabled". If that change fixes the issue, and ...
Read more >
ASP.NET Core - correlation failed error message
Now I'm getting an error like: An unhandled exception occurred while processing the request. HttpRequestException: Response status code does not ...
Read more >
"Sign in as User" Feature throws "Correlation failed ...
When the “Sign in as User” Feature is used it throws a “Correlation failed” Exception. Targeting ASP.Net Core 2.1. Stacktrace: System.
Read more >
Exception: Correlation failed. - Prateek Gangwar - Medium
This exception keeps occurring while working on a web application using ASP.NET Core. ... At last, I've found a hook on the middleware...
Read more >
What is “HTTP 500 Internal Server Error” and How to Fix It?
When you encounter an error 500, it means that the server has encountered an unexpected condition or configuration problem that prevents it from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found