-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UnknownSessionKeyException - errors for registered keys #322
Comments
Are you sure it's a Guid? In order to serialize, it must match the name as well as the type registered? Can you show an example of where you set the session value for SessionToken? |
I've added a PR to give better warnings for if the type is not correct (not sure if that is the issue here, but we don't have good diagnostics on that) |
I figured out what was wrong with my setup. One of the shared class libraries was missing a Microsoft.AspNetCore.SystemWebAdapters package. Right now, everything is working as expected. I overlooked that installing the package to the class libraries is required. Thanks a lot for the help and this fantastic package, it is a new life for our old and rusty application 😄 |
Great! Sounds like the PR to have better logging for type issues will help here. I'll go ahead and close this issue. Please raise a new one if you have more issues |
Describe the bug
When trying to read Session from the .NET 7 application, I receive UnknownSessionKeyException. It provides a list of unknown session keys, but the issue is that it lists registered session keys.
To Reproduce
Here is the code for the Program.cs file of .NET 7 application:
As you can see, I only added
SessionToken
as a known key. The same applies to the Global.asax code in the ASP.NET Framework app:When I run the application and attempt to hit the endpoint in which I read the Session, I receive the following error:
What confuses me is why the error lists SessionToken, amongst other unregistered session keys.
I tried turning the
ThrowOnUnknownSessionKey
option off, and then I didn't receive the exception from the above image, but there are no values in Session.Should I include something in my configuration, or must I register all the keys for the session to work correctly?
Further technical details
ASP.NET Framework Application:
ASP.NET Core Application:
The text was updated successfully, but these errors were encountered: