views:

285

answers:

3

Hi,

We are going to update our asp.net application to save session in state server. Any attention required to avoid problems after the update?

It is going to run in IIS 6 and IIS 7.

Thanks, P.Gopalakrishnan

A: 

Not tried this on IIS7, but on IIS6 it was simply a case of modifying the web.config to specify the state server. John Saunders is however correct above about the serialisation issue, guess I was just lucky but I will be changing all of my development to use State Server in future as recommended by Brian Reiter.

One nice side effect is that you can increase the number of worker processses when using a state server because they can all share the state from the server (whereas normally the state would in in-process).

Note from MSDN:

To use StateServer mode in a Web farm, you must have the same encryption keys specified in the machineKey element of your Web configuration for all applications that are part of the Web farm. For information on how to create machine keys, see article 313091, "How to create keys by using Visual Basic .NET for use in Forms authentication," in the Microsoft Knowledge Base at http://support.microsoft.com.

Martin Robins
+2  A: 

I believe that StateServer will enforce the requirement that all objects stored in Session must be serializable. This may not have been enforced by InProc.

Be sure to test before going into production.

John Saunders
I am fairly certain that all objects that are saved in state have to be serialisable, irrespective of the state storage method in use.
Martin Robins
If you have been developing on InProc session it is pretty likely that you will be bitten by the serialization issue unless you were very cognizant of it. We usually develop against StateServer even if the application will likely be deployed InProc because of this serialization gotcha.
Brian Reiter
Just looked this up in MSDN and you are indeed correct: "Objects stored in session state must be serializable if the mode is set to StateServer. For information on serializable objects, see the SerializableAttribute class."
Martin Robins
@Martin: Thanks, I knew I was correct. :-) Actually, it's because a recent post on SO was from someone who was bitten by this exact issue. I was just to lazy to find it and post the link.
John Saunders
A: 

You need to ensure objects that you currently store in session state are marked as serializable The refactoring can be substantial

http://msdn.microsoft.com/en-us/library/ms178581.aspx

Stuart