Reputation: 5670
So, this morning we lost power to our server hosting our MVC3 website. Since it has come back on line, we are randomly losing our session values. This only happens on this server, not on local or staging servers. This has nothing to do with timeouts, as the session clears after as few as 5 minutes. Session is set to expire after 12 hours. The SessionID for the session doesn't change when the values are lost.
I'm using Log4Net and have added a lot of logging to try and pinpoint this issue. I have added Session_Start and Session_End events to Global.asax as well as checks for session values all through out my controllers.
I have an Index view that displays a list of items. Each item in the list has a link that takes you to a Details view. I check the session values on each Action call. The session values always seem to go missing when calling back to the Index view from the Details view. What I have noticed is that each time my session values are lost, there is a Session_Start event that fires.
There isn't a Session_End event, only a Start. What would cause this Start to happen?
If there is any more info I can provide, please comment and I will add what I can.
Upvotes: 2
Views: 1494
Reputation: 5670
This ended up being a hardware issue. This web server is a virtual machine. It seems the power outage we had affected all of our virtual servers, causing a lot i/o issues as well as memory issues. I did narrow down the area in my application where the state was lost, but it wasn't consistent at all.
Since they restarted the virtual server host computer we aren't experiencing the problems anymore.
Upvotes: 0
Reputation: 35407
If your using InProc
SessionState then your Application Pool may be recycling in the middle of some of your sessions. To remedy use SQLServer SessionStateMode, StateServer SessionStateMode or mitigate application pool recycles.
http://msdn.microsoft.com/en-us/library/ms178586.aspx
SQLServer mode stores session state in a SQL Server database. This ensures that session state is preserved if the Web application is restarted and also makes session state available to multiple Web servers in a Web farm.
Upvotes: 3