4

I have this setting in the web.config file: <sessionState timeout="540" />. This tries to make all the sessions expires after 8 hours. However, the session expires much faster than that and I got an object reference not set to an instance of an object error. Could some tell me if there is something else affects the session?

Thanks in advance!

Niventh
  • 985
  • 2
  • 9
  • 23
  • Which SessionStateProvider are you using? How many web servers do you have/use for the application? Are you using the same browser on the same computer? Is anything clearing cookies before your session(s) expire and does the browser remain open throughout? – pwdst Mar 02 '13 at 15:58

1 Answers1

8

SessionState expires also if the application pool recycles (inactivity, exception, or configuration).

Anyway, it is not a best practice to extend the SessionState timeout so much.

maybe you should change you dependency to session or use a different way to persist those objects (viewstate).

If you absolutely need to have session to persist so much you should use another server or a db as session store.

http://msdn.microsoft.com/en-us/library/ms178586(v=vs.100).aspx

MrBoJangles
  • 12,127
  • 17
  • 61
  • 79
giammin
  • 18,620
  • 8
  • 71
  • 89
  • 1
    If you want to disable the IIS app pool time-out: https://stackoverflow.com/questions/1596267/how-to-disable-the-application-pool-idle-time-out-in-iis7 – MrBoJangles May 16 '19 at 18:19