2
votes

On page load I am populating my own object, storing in session & it is getting stored, When I am debugging i can see that object is stored in session, But When I am reading that session variable.. it is null,

Surprizingly I am able to use other session variables,

Howerver I am able to get the session variable when my sessionstate = "InProc"... and I get it null when sessionstate='StateServer' or sessionstate='SQLServer'

I've kept session TimeOut="20", On the page I've added EnableSessionState="True"

Please help, - Prashant C

2
Could you post your code? If you can use other session variables, what are you doing differently? - Peter
marking your classes as Serializable and implementing IDeserializationCallback support.microsoft.com/kb/312112 - PRR

2 Answers

2
votes

Does your type implement ISerializable (directly or indirectly, perhaps via inheritance)? The biggest difference between in-proc and the rest is that in-proc doesn't serialize, so serialization is the first thing to look at.

It does sound very odd, though - if it was "off", I would expect to get either an exception or an uninitialised object - not a null. Maybe a silly question, but the incoming request definitely has all the right headers/cookies? i.e. it still knows which session it is in?

To explain, if your type neither implements ISerializable nor has [Serializable] I would expect an exception; you've added [Serializable], but the fact that it didn't already error makes me think there is some ISerializable in the mix.

1
votes

sessionstate='StateServer' or sessionstate='SQLServer' requires that your Objects are serializable.