2

I have an ASP.NET MVC application. For some users we have the problem that from time to time their session context (in HttpContext.Current.Session) disappears (is cleared). The session state element in the web.config looks like this:

<sessionState mode="StateServer" timeout="320" />

I check if session timed out like this:

HttpContext.Current.Session.IsNewSession

But this was not the case. The values just disappeared.

What can cause this to happen? Could local settings influence the session context?

Palmi
  • 2,381
  • 5
  • 28
  • 65
  • Related: [Losing Session State](http://stackoverflow.com/q/3515947/181087), [ASP.NET randomly losing session values](http://stackoverflow.com/q/6958775/181087), [Don't redirect after setting a Session variable](http://weblogs.asp.net/bleroy/Don_2700_t-redirect-after-setting-a-Session-variable-_2800_or-do-it-right_2900_), [Session variable and Cookies losing value](http://forums.asp.net/t/1811915.aspx?Session+variable+and+Cookies+losing+value) – NightOwl888 Jul 07 '16 at 20:53
  • But IMO, this one is the most important: [Think twice about using session state](https://brockallen.com/2012/04/07/think-twice-about-using-session-state/). If you find alternatives to session state, it will keep you from having to spend countless hours troubleshooting when it "disappears" unexpectedly. – NightOwl888 Jul 07 '16 at 20:55
  • Thank you for all this information. But I already store my session out-of-proc or do I misunderstand the State Service (mode="StateServer")? – Palmi Jul 07 '16 at 21:28

0 Answers0