Serialize UserControls For MSSQL Session State

Last post 03-26-2008 3:10 PM by gunteman. 3 replies.

Sort Posts:

  • Serialize UserControls For MSSQL Session State

    03-25-2008, 1:12 PM
    • Member
      4 point Member
    • Liquid90605
    • Member since 03-25-2008, 5:10 PM
    • Posts 7

    Hello,
    I have some code that already exists. This code needs to support ASP.net Session State in MSSQL mode.
    The problem is that there is something in session which can't be serialized and causes an error: "Un-Serializable object in session". I have found that this object in session that is casing the problem is an ArrayList of User Controls.

    I set out to make the User Controls serializable. I set the serializable attribute on the class and implimented ISerializable with the hetOgjectData Method. None of this changed anything. I still get the same error.

    This problem can be replicated by making a new projec and, setting session state to use MSSQL in web.config. Then trying to add a few empty user controls with Serializable attribute set and using ISerialzable to an Arraylist in session. The error will still come up, I tried it.

    Thanks in advance.

  • Re: Serialize UserControls For MSSQL Session State

    03-25-2008, 2:53 PM
    • All-Star
      21,646 point All-Star
    • gunteman
    • Member since 07-11-2007, 8:57 AM
    • Norrköping, Sweden
    • Posts 3,176

     Why store user controls in Session, in the first place? User control instances are transient in nature, and not really suitable to store in Session.

    -- "Mark As Answer" if my reply helped you --
  • Re: Serialize UserControls For MSSQL Session State

    03-26-2008, 1:43 PM
    Answer
    • Member
      4 point Member
    • Liquid90605
    • Member since 03-25-2008, 5:10 PM
    • Posts 7
    The code was created by a subordinate of mine. I was looking for a quick fix. In the end I had to take the time to step through and re-code the application to not use the user controls in session.
  • Re: Serialize UserControls For MSSQL Session State

    03-26-2008, 3:10 PM
    • All-Star
      21,646 point All-Star
    • gunteman
    • Member since 07-11-2007, 8:57 AM
    • Norrköping, Sweden
    • Posts 3,176

    Good! 

    -- "Mark As Answer" if my reply helped you --
Page 1 of 1 (4 items)