LoginCallback.ashx throws error

I copied the code from the MVC sample and created the ashx inside my asp.net application (not MVC)

I got the valid token from authentication but the code throws an error at this line:

Error: ‘FederatedAuthentication.SessionAuthenticationModule’ threw an exception of type ‘System.InvalidOperationException’

StackTrace = " at System.IdentityModel.Services.FederatedAuthentication.GetCurrentContextItems()\r\n
at System.IdentityModel.Services.FederatedAuthentication.GetHttpContextModuleMap()\r\n
at System.IdentityModel.Services.FederatedAuthentication.GetHttpModuleT.…

Can someone help me with this?

Million thanks!

As it has been more than a few months since this topic was opened, and there has been no reply or further information provided as to the existence of the issue, we are closing this topic. Please don’t hesitate to create a new topic if this issue is still present, we would be happy to work with you to help find a resolution.