2

In my web.config I have this:

<sessionState timeout="70"/>

However, after 5 minutes my session is null and my program crashes. How to make this time longer?

Here is how I initialize it:

Session["mySession"] = "blah blah";
petko_stankoski
  • 10,459
  • 41
  • 127
  • 231

3 Answers3

2

Modify the timeout like this:

HttpContext.Current.Session.Timeout = 200000
mghaoui
  • 563
  • 2
  • 7
  • 15
1

Check the applicationpool timeout http://technet.microsoft.com/nl-nl/library/cc771956%28v=ws.10%29.aspx

Using forms authetication? It got it's own timeout/

Ivo
  • 3,406
  • 4
  • 33
  • 56
  • Does it happen on your dev environment our on production, your sure you are not "building" your application in between and not changing the web.config – Ivo May 11 '12 at 12:51
  • Also check out this question for a couple of solutions http://stackoverflow.com/questions/3515947/losing-session-state – Ivo May 11 '12 at 12:52
  • I'm not changing the web. config. I run my app, login, everything is fine, I wait 5 minutes and crash. – petko_stankoski May 11 '12 at 12:52
0

the time that you putting inside the Web.Config

<sessionState timeout="60"/> (it in minutes)

affect on the

HttpContext.Current.Session.Timeout = 60

or

 System.Web.HttpContext.Current.Session.Timeout = 60
Vladi
  • 1,662
  • 19
  • 30