How does reloading an application pool affect ASP Net session state?

I know when the application pool is processed, a new workflow is initiated, but I do not agree with how expired and valid sessions are handled in this process? which moves to a new workflow and is being eliminated? what will he do with:

  • Session User Expiration
  • User user session is valid

after reuse, when user A and user B ask what their statet session will be?

+5
source share
2 answers

If you have one web server, and you used the default InProc mode for the duration of SessionState, then any data that you added to the session dictionary in your server code will be lost when you reuse the application pool - after transcoding, when your code the next one accesses the entry in the SessionState dictionary, it will return null .

Similarly, this will happen if you have several web servers in the load balancer, the session state is incorrectly configured as InProc , and the user returns to another server (i.e. without sticky routing).

(The session state cookie stored in the browser may remain valid for several minutes).

A way to allow the session state to "survive" the reboot of the application pool, server crash, or going through the server farm is to save the data stored in SessionState so that the server (or servers) can retrieve the data when the user session returns. The easiest way is to use one of the solutions from the box , namely a separate StateServer process or save the state in the SqlServer database. User persistence is also an option.

One warning - note that any data stored in "off-process" mode, such as StateServer or SqlServer , must be serializable - this may be a change when disconnected from InProc .

+7
source

I found this article very useful for understanding restarting and restoring an application pool. https://blogs.msdn.microsoft.com/tess/2006/08/02/asp-net-case-study-lost-session-variables-and-appdomain-recycles/

0
source

Source: https://habr.com/ru/post/1239567/


All Articles