0

I'm working on a ASP Net MVC system, and the problem i'm having since the begining is that my session variables and static variables are getting reset after some time around 30-45 minutes (but i'm not sure it happens always). The options i've already tried: * Change session timeout from the config file * Check recycling time * Use server state session instead of in process * Maybe something else i don't remember I don't know what else to try, or where to investigate, and i don't have a certain clue at the moment. It's really annoying when trying functions while developing. Any ideas?

Config file

<sessionState timeout="120" />

Pool config

Tinchio
  • 11
  • 5

2 Answers2

0

As far as I know, in IIS version 7.0 and above, the worker process terminates after a period of inactivity by default(20min).

Because of this, if Secret Server is in its own application pool, the application pool will stop after a period of no requests.

I suggest you could follow below steps to modify application pool settings to keep the web application always running to avoid session missed.

  1. Open IIS (Start > inetmgr)
  2. Right-click the application pool, and then click Advanced Settings.
  3. Under the Process Model section, set the Idle Time-out (minutes) option to 0

enter image description here

Brando Zhang
  • 22,586
  • 6
  • 37
  • 65
  • But 0 minutes means it'll never reset sessions. Won't it drastically reduce the server performance? In my case it's set to 240 minutes, but still session is reset before as i explained before – Tinchio Apr 04 '19 at 00:09
  • Normally, the session will not expire before the session timeout. I guess the reason is the web application restart. I suggest you could follow this [answer](https://stackoverflow.com/a/41870086/7609093) to find out the restart reason. – Brando Zhang Apr 08 '19 at 09:03
0

Not sure if this is your problem, but one possibility that caused me far too much head-to-wall banging is: your deployed IIS has the AppPool Maximum Worker Processes set to something greater than 1 (note that @BrandoZhang's screenshot above has it set to 1). Static variables, classes, and even ApplicationState aren't shared across processes.