Sharing Session State between different .NET Versions using State Server Sharing Session State between different .NET Versions using State Server asp.net asp.net

Sharing Session State between different .NET Versions using State Server


.NET 3.5 and .NET 4 run different versions of the CLR. Object serialization (which is used for storing session state when not using InProc) differs between .NET versions. It's likely that the object is failing to be deserialized on another platform so it silently drops it. You would have the same problem if you use SQL Server as a Session State server too.

Assuming this is the problem then you're going to have to ensure both sites are on the same .NET version, or perform your own serialization to disk or SQL Server.


StateServer and SQLServer state management also uses the application path (in addition to the application name) in creating the key for session data.

Your application is showing the same SessionID due to the cookie being read by both apps, however the application path must be the same as well to actually read the same session data on the state server.

You can change that to the same value with an extra overwrite in your Application_Start for this variable:

FieldInfo appPathInfo = typeof(HttpRuntime).GetField("_appDomainAppPath",     BindingFlags.Instance | BindingFlags.NonPublic);appPathInfo .SetValue(theRuntime, applicationName);