Reputation: 11383
Weired problem! ASP.NET Session expires instantly. In my web.config I have this session settings:
<sessionState mode="InProc" timeout="10000" />
AFAIK the timeout attribute's value is in minutes and can't be greater than 525,600 minutes (1 year). I don't understand what I am doing wrong here. Why is the session expiring. Is it a server memory issue? I don't think so, the server is pretty descent and it has only one site which isn't doing much after all. Ideas?
EDIT:
After setting the cookiless attribute to true, and while noticing the session id on the url, I can see that the session id CHANGING. I assume that this means the session is expiring. The IIS Settings are correct AFAIK (the enable session state checkbox is checked, and the value of the time is 20). A Picture is worth 100 words:
alt text http://img148.imageshack.us/img148/5053/sessionstate.jpg
Upvotes: 0
Views: 3125
Reputation: 11383
It turned to be a mistake of one of our team members, he was setting the session to be inproc though the site was distributed of 4 physical machines with Load-Balancing. I'm not sure if it's the problem though, but when I changed it to store the session in a SQL server, it worked! Will dig deeper this issue and report any further information I might get. Thanks you all Guys!
Upvotes: 0
Reputation: 17382
This has happened to me a couple of times and the main culprits have always been.
Someone updated a file in the web application causing it to restart, this normally happens when someone decides to update something in the web.config without realising this causes all the sessions to be dropped.
The other thing that has caused it for me is a setting in IIS that defines how long sessions last, if you go into the properties of your virtual directory/web site and click configuration, on the options tab is a session timeout duration check this is enabled and set to a high enough value.
Upvotes: 0
Reputation: 6612
I had this happen with a page once. It turns out that I was doing a Session.Abandon() in a place that I did not realize was called in the execution sequence (it related to login and the way I was using the membership provider). As a debugging tip, I would recommend putting a breakpoint on every Session.Abandon() and making sure that it's not being called when you don't expect it.
Upvotes: 0
Reputation: 102478
You need to make sure Session is enabled with IIS as well as in the web.config.
Also, it's worth putting some logging on the Application Restart. You might have something else going wrong that is causing the whole app to reset.
Upvotes: 0
Reputation: 70414
Perhaps your browser doesn't store cookies correctly. Try setting session to cookieless
mode and try again.
<sessionState mode="InProc" timeout="10000" cookieless="true" />
Upvotes: 1