Object gets stored in session, but while retrieving it is null

Last post 11-23-2009 5:11 AM by satalaj. 4 replies.

Sort Posts:

  • Object gets stored in session, but while retrieving it is null

    11-18-2009, 4:16 AM
    • Member
      1 point Member
    • prashantc
    • Member since 08-25-2008, 7:04 AM
    • Posts 5

    Hi all,

    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

  • Re: Object gets stored in session, but while retrieving it is null

    11-18-2009, 4:37 AM
    • Star
      9,566 point Star
    • satalaj
    • Member since 11-28-2007, 12:41 AM
    • Pune
    • Posts 1,874

    Hi.
     Do you mean you are loosing session if you use SQL server or State machine ?
    Have you configured your session management properly.

    -Satalaj 

  • Re: Object gets stored in session, but while retrieving it is null

    11-18-2009, 5:04 AM
    • Member
      1 point Member
    • prashantc
    • Member since 08-25-2008, 7:04 AM
    • Posts 5

    Yes satlaj.. as i am able to access other session variables like useriD and all..

    I think I've done it properly.. but please continue your suggestions are welcome.


  • Re: Object gets stored in session, but while retrieving it is null

    11-18-2009, 7:28 AM
    Answer
    • Member
      1 point Member
    • prashantc
    • Member since 08-25-2008, 7:04 AM
    • Posts 5


    Hi all, The issue is solved...

    I did a silly mistake.. I had forgot to add [serializable] to class definitions  of data members contained in my wrapper class..

    [seriablizable]

    class class_first

    {

    ...

    class second = new class_second();

    ...

    }


    I had made only class_first as [serializable]  and not class_second...

    I was not finiding any errors because of an error handling module..

    But I hope this helps to all others


    I really appreciate your time and help,

    Cheers  !!

    - Prashant C

  • Re: Object gets stored in session, but while retrieving it is null

    11-23-2009, 5:11 AM
    Answer
    • Star
      9,566 point Star
    • satalaj
    • Member since 11-28-2007, 12:41 AM
    • Pune
    • Posts 1,874

    Yes,
     when we are storing session state using SQL server or State server or custom third party softwares.
    we must mark the objects as  serializable. Bcoz our application is communicating across the application domain.

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

    Satalaj

Page 1 of 1 (5 items)