locked
Session timeout problem RRS feed

  • Question

  • User982455623 posted
    Hi,
     
    i'm storing the DataTable information into Session . in the same page i'm calling that Session obj.
     gbds = ((DataTable)Session["datatable"]).Clone();
    
    i have a data in my session object. sometimes it's working fine but sometimes its show the error " Object reference not set to an instance of an object ".
    i know the session Default timeout is 20min, but my browser ideal time is just 1 or 2 min. In that also it's shows that error message. for that i run that application in sharepoint site but here also it's shows the same problem. What's the wrong in that can any one help me what's the problem on here.
     

    Thankx in advance...
    Friday, October 12, 2012 3:23 AM

Answers

  • User-1910946339 posted

    Your question is headed "Session timeout problem" but in the original post you seem to say that the session could not be timing out.  So, why did you call the question "Session timeout problem"?  What makes you think something is timing out?

    It seems more likely to me (and it is only a wild stab in the dark because you have not shown enough code to tell) that there are circumstances under which the session variable is not written/created.  But it is impossible to tell with the information you have given.

    Regardless, you code should check if the session variable "datatable" exists and take appropriate action rather than just falling over.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 12, 2012 8:32 PM
  • User1320101480 posted

    The code posted by you shows the access of DataTable from Session, maybe the Session is not expiring but somwhere the code which puts the DataTable into the Session isn't getting executed.

    If this is not the case, then before you access your DT varialbe check if session is available or not.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, October 13, 2012 9:12 AM

All replies

  • User700362322 posted

    may be http://forums.asp.net/t/1538529.aspx/1 can help you.

    Friday, October 12, 2012 3:53 AM
  • User1725023780 posted

    session get expired unexpectedly due to many reasons. below link may help you.

    http://zeeshanumardotnet.blogspot.in/2009/07/why-sessions-are-terminatedloss.html

    Friday, October 12, 2012 4:02 AM
  • User-1910946339 posted

    Your question is headed "Session timeout problem" but in the original post you seem to say that the session could not be timing out.  So, why did you call the question "Session timeout problem"?  What makes you think something is timing out?

    It seems more likely to me (and it is only a wild stab in the dark because you have not shown enough code to tell) that there are circumstances under which the session variable is not written/created.  But it is impossible to tell with the information you have given.

    Regardless, you code should check if the session variable "datatable" exists and take appropriate action rather than just falling over.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 12, 2012 8:32 PM
  • User1320101480 posted

    The code posted by you shows the access of DataTable from Session, maybe the Session is not expiring but somwhere the code which puts the DataTable into the Session isn't getting executed.

    If this is not the case, then before you access your DT varialbe check if session is available or not.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, October 13, 2012 9:12 AM
  • User-735357247 posted

    Instead of storing the datatable in session, try storing the datatable in cache. cache is the ideal solution for this type of scenarios

    Monday, October 15, 2012 6:23 AM