应用程序池回收如何影响ASP Net Session State? [英] How does an application pool recycle affect ASP Net Session State?

查看:87
本文介绍了应用程序池回收如何影响ASP Net Session State?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道何时回收应用程序池时会启动一个新的工作进程,但是我对在此进程中如何处理过期和有效的会话感到困惑?哪些传递给新的工作进程线程,哪些被消除?它将做什么:

I know when application pool is recycled a new worker process is initiated but I am confused with how expired and valid sessions are treated in this process? which passes to new worker process thread to and which are eliminated? what it will do with:

  • 用户A的会话已过期
  • 用户B的会话有效

回收后,当用户A和用户B请求时,他们的会话状态是什么?

after recycling, when User A and User B will request then what will be their session statet?

推荐答案

如果您有一台Web服务器,并且对SessionState持久性使用了默认的InProc模式,则添加到该服务器上的所有数据服务器池代码中会话的词典"将在应用程序池回收期间丢失-回收后,当您的代码下次访问SessionState词典中的条目时,它将返回null.

If you have a single web server, and you've used the default InProc mode for SessionState persistence, then any data that you've added to the session's Dictionary in your server code will be lost during an App Pool recycle - after the recycle, when your code next accesses an entry in the SessionState dictionary, it will return null.

如果您在负载均衡器上有多个Web服务器,并且会话状态错误地配置为InProc,并且用户返回到另一台服务器(即,没有粘性路由),也会类似地发生这种情况.

This will similarly happen if you have multiple web servers across a load balancer, with session state incorrectly configured as InProc, and the user returns to a different server (i.e. without sticky routing).

(存储在浏览器中的会话状态cookie可能在几分钟内仍然有效).

(The Session State cookie stored on the browser may still be valid for several minutes yet).

允许会话状态生存"应用程序池回收,服务器崩溃或跨服务器场的方法是持久性存储在SessionState中的数据,以便服务器(或多个服务器)可以再次检索用户会话返回时的数据.最简单的方法是使用一种即用型解决方案,即单独的StateServer进程,或将状态存储在SqlServer数据库中.自定义持久性也是一种选择.

The way to allow Session State to 'survive' an App Pool recycle, server crash, or to span across a farm of servers is to persist data stored in SessionState, so that the server (or servers) can again retrieve the data when the user's session returns. Easiest is to use one of the out of the box solutions, viz a separate StateServer process, or store state in a SqlServer database. Custom persistence is also an option.

一个警告-请注意,以进程外"模式存储的所有数据(例如StateServerSqlServer)都需要可序列化-当您退出InProc时,这可能是一个重大更改.

One caveat - note that any data that you store in an 'out of process' mode such as StateServer or SqlServer needs to be serializable - this can be a breaking change when you switch out of InProc.

这篇关于应用程序池回收如何影响ASP Net Session State?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆