0

I'm currently working on an application that stores its Session State in process. Due to the way the application has been written when we release the application / app pool recycle the session data is lost and the user is logged out.

This isn't great for three reasons:

  1. Upgrading software logs users out
  2. Difficult whilst fixing bugs as when we rebuild the solution the developer has to navigate back to the page he/she is working on which takes time.
  3. We are looking to move to load balanced infrastructure

I've decided to move Session State to StateServer to prevent the Session being lost.

A pre-requisite for using StateServer is that all objects stored in Session must be Serializable and therefore must explicitly be decorated with the System.SerializableAttribute.

So I've found myself manually going through the whole object graph of our SessionData object (which is quite large) and it's taking some time.

I've stopped at this point as this seems like quite an erroneous task.

I also found that our root SessionData object could be stored in session state fine even with properties that weren't decorated with the Serializable attribute providing that they were null. So without going through everything I wouldn't know until an Exception was thrown.

So my questions are:

  1. Am I making the correct decision to move Session State out of process (we may be moving to a load balancing model so I think this will need to be the case)
  2. Is it correct that I need to manually go through the whole object graph and explicitly add the System.SerializableAttribute.

Thanks in advance.

Tom Miller
  • 431
  • 1
  • 5
  • 16
  • 1
    answer is yes for this ... – Pranay Rana Feb 03 '15 at 11:20
  • @PranayRana Well that's a joy – Tom Miller Feb 03 '15 at 11:26
  • 1
    Yes to both these points. I would point out though that you only need to mark [Serializable] attribute at class level (wan't sure from your post if you were putting it at property level). – Dave Becker Feb 03 '15 at 12:13
  • 1
    Also make sure, when you add a load balancer to copy the machine key to the web config of each balanced application instance – Dave Becker Feb 03 '15 at 12:14
  • Did you ever find a way of checking your object graph without having to do it completely manually? I have much the same issue, with 100s of objects that might not be serializable being added to session, some of those being .NET classes so I can't even subclass them. – David Keaveny Feb 08 '16 at 15:56
  • @DavidKeaveny Hi Daviid - you won't like my answer but we decided to postpone this as it was quite risky without a lot of testing. I didn't find a way I'm afraid. – Tom Miller Feb 10 '16 at 11:13

0 Answers0