We are trying to decide how to handle object persistence accross postbacks, to avoid getting the data from the database in every request, and I’m leaning towards using Session (it’s an intranet application, there won’t be thousands of users), but this is due to the fact that I suspect that only the reference to the real object is stored there…
Does anyone know for a fact if this is true?
I’ve always been taught not to over use the session object, but if it works this way it wouldn’t really be a big problem…
What is really stored in session here:
Session['myKey'] = myObject;
The actual serialized object, or its reference?
I have tried this:
I have created a class and store an instance of this in session (session state mode: InProc). Instance lives in aspnet_wp.exe proc.
Then, I changed session state to SQL Server (still without [Serializable] attribute) and I got the following error.
Unable to serialize the session state. In ‘StateServer’ and ‘SQLServer’ mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted.
So, there is no serialization for inProc session state.
Cheers… Martín