ASP.Net中的会话超时设置

时间:2021-03-30 03:33:35

I have set session time out to 9 hours in web.config file something like this:

我在web.config文件中将会话时间设置为9小时,如下所示:

“<sessionState mode="InProc" timeout="540" />

But often users complain that they are facing time out in less than 9 hours of inactivity and the time interval after they are timed out also varies.

但是,通常用户抱怨他们在不到9小时的时间内面临超时,并且超时后的时间间隔也会有所不同。

I was wondering if session time out is dependent on any of the below settings in IIS:

我想知道会话超时是否依赖于IIS中的以下任何设置:

  1. Session time setting
  2. 会话时间设置
  3. Idle- time out setting for Application pool
  4. 应用程序池的空闲超时设置
  5. Recycling setting.
  6. 回收设置。

Please advise. Also, how do I check session time out setting in IIS 7.0?

请指教。另外,如何在IIS 7.0中检查会话超时设置?

3 个解决方案

#1


11  

The session will be lost when the ApplicationPool recycles. That's one of the IIS settings that you mentioned. To set only the timeout in the web.config will not be enough. You need to adjust the setting in IIS.

ApplicationPool回收时,会话将丢失。这是您提到的IIS设置之一。仅在web.config中设置超时是不够的。您需要在IIS中调整设置。

Here is a link I found while I was looking into the same problem.

这是我在查看同样问题时发现的链接。

Also, this question was very useful: Losing Session State

此外,这个问题非常有用:失去会话状态

#2


0  

If you are using Forms authentication you should make sure your FormAuthentication Cookie is set to expire at the same time as your Session.

如果您使用的是表单身份验证,则应确保将FormAuthentication Cookie设置为与会话同时过期。

If not make sure your IIS is not getting recycled. ( put a logger in your Global.asax to verify the application end events compared to your users complaints.)

如果不确保您的IIS没有被回收。 (在您的Global.asax中放置一个记录器,以验证与用户投诉相比的应用程序结束事件。)

#3


0  

It is not enough to set session time out in your web config. If the server on which your site is hosted is having less time out value set in IIS setting, your session is time out according to the server session time out value.

仅在Web配置中设置会话超时是不够的。如果托管站点的服务器在IIS设置中设置的超时值较少,则会话将根据服务器会话超时值超时。

also if you are deleting any folder from the server directory, this can also cause your AppPool to recycle unexpectedly.

此外,如果要从服务器目录中删除任何文件夹,这也会导致AppPool意外回收。

so please check the server session time out value and if it less then ask your hosting to increase it as per your requirement.

所以请检查服务器会话超时值,如果少,请要求您的主机根据您的要求增加它。

#1


11  

The session will be lost when the ApplicationPool recycles. That's one of the IIS settings that you mentioned. To set only the timeout in the web.config will not be enough. You need to adjust the setting in IIS.

ApplicationPool回收时,会话将丢失。这是您提到的IIS设置之一。仅在web.config中设置超时是不够的。您需要在IIS中调整设置。

Here is a link I found while I was looking into the same problem.

这是我在查看同样问题时发现的链接。

Also, this question was very useful: Losing Session State

此外,这个问题非常有用:失去会话状态

#2


0  

If you are using Forms authentication you should make sure your FormAuthentication Cookie is set to expire at the same time as your Session.

如果您使用的是表单身份验证,则应确保将FormAuthentication Cookie设置为与会话同时过期。

If not make sure your IIS is not getting recycled. ( put a logger in your Global.asax to verify the application end events compared to your users complaints.)

如果不确保您的IIS没有被回收。 (在您的Global.asax中放置一个记录器,以验证与用户投诉相比的应用程序结束事件。)

#3


0  

It is not enough to set session time out in your web config. If the server on which your site is hosted is having less time out value set in IIS setting, your session is time out according to the server session time out value.

仅在Web配置中设置会话超时是不够的。如果托管站点的服务器在IIS设置中设置的超时值较少,则会话将根据服务器会话超时值超时。

also if you are deleting any folder from the server directory, this can also cause your AppPool to recycle unexpectedly.

此外,如果要从服务器目录中删除任何文件夹,这也会导致AppPool意外回收。

so please check the server session time out value and if it less then ask your hosting to increase it as per your requirement.

所以请检查服务器会话超时值,如果少,请要求您的主机根据您的要求增加它。