Unclear how to catch "System.Exception: Correlation failed." and prevent HTTP 500
See original GitHub issueIs 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?
- Package versions:
- Microsoft.AspNetCore.Authentication.OpenIdConnect version 6.0.8
- Possibly relevant discussions that other people have had around the same issue circa 2018 with workarounds
Issue Analytics
- State:
- Created 9 months ago
- Reactions:6
- Comments:7 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
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.