增加会话超时 [英] Increasing Session TimeOut

查看:162
本文介绍了增加会话超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过的托管

网站IIS 7.0

我想我的会话超时设置为我的ASP.NET应用程序9小时。结果
这已被设定在的web.config

 <的sessionState超时=540>< /&的sessionState GT;

不过,按照我的理解,如果超时设置为IIS 20分钟内,其中的网站托管,设定一个扩展的会话状态将是没有用的。

首先,我想证实这个假设是否正确。

问题是,我没有访问我的共享托管的Web服务器的IIS。

现在,一些研究后,我想出了在code项目的另一种解决方案。这听起来像一个 绝妙的主意 。我们的想法是插入一个iframe来母版页。在iframe包含另一个网页的元刷新不到20分钟。

  Response.AddHeader(刷新,20);

这个想法似乎对我好。但文章是7岁。加上评论部分用户的抱怨,如果页面最小化,我很担心,同样的情况发生时,我的网页标签不活跃,这将无法工作。

我想知道这些事情。


  1. 是否刷新方法将我的情况下工作,即使页面最小化?

  2. 是否有任何其他的方法,可以增加覆盖IIS超时设置?
  3. 会话超时
  4. 此外,我读堆栈溢出的一些问题,其中的的答案状态IIS会话超时是CLASIC ASP页的。那么,为什么不是我延长超时不费一枪?


解决方案

  

首先,我想证实这个假设是否正确。


是的,这个假设的情况下,绝对正确的,你正在使用的内存中会话状态模式。在这种情况下,会被存储在内存中,因为IIS可以推倒在不同情况下的AppDomain(不活动期间,CPU /内存tresholds均达到,...)会话数据都将丢失。你可以使用进程外的一个会话状态模式。无论的StateServer或SQLServer的。在第一种情况下在会话存储在运行ASPState的Windows服务一个特别专用计算机的存储器中并在所述第二情况下,它是一个专用的SQL Server。在SQL Server是最强大的,但显然最慢的。


  

1)是否刷新方法将我的情况下工作,即使页面最小化?


隐藏的iframe仍然工作,以保持该会话还活着,但正如我所说previously可能有一定的条件时,IIS反正卸载应用程序(CPU /内存tresholds均达到=>你可以在IIS中配置此以及)


  

2)是否有任何其他的方法,可以增加覆盖IIS超时设置会话超时?


在previous方法不增加会话超时。它只是通过定期发送HTTP请求到服务器,以prevent从带来的AppDomain下IIS保持会话活着。


  

3)此外,我读堆栈溢出一些问题,其中的答案状态
  在IIS会话超时是CLASIC ASP页。那么,为什么不
  我延长超时不费一枪?


有没有这样的事情作为IIS会话超时。这次会议是一个ASP.NET神器。 IIS是Web服务器,不知道什么会议

我个人不使用我的应用程序会话。我只是禁​​用它们:

 <的sessionState模式=关>< /&的sessionState GT;

和使用标准的HTTP文物,如饼干,查询字符串参数,......维护状态。我preFER在我的后端坚持信息和检索在以后通过唯一的ID,而不是依赖于会话。

Site hosted via IIS 7.0

I would like to set my session time-out to 9 hours in my ASP.NET application.
This has been set at web.config

<sessionState timeout="540"></sessionState>

But, as I understand, if the timeout is set as 20 minutes inside the IIS where the website is hosted, setting an extended session state will be of no use.

Firstly, I would like to confirm whether this assumption is right.

The problem is that I do not have access to the IIS of my shared hosted web server.

Now, after some research, I came up with another solution in code project. This sounds like a wonderful idea. The idea is to insert an iframe to master page. The iframe will contain another page with meta refresh less than 20 minutes.

 Response.AddHeader("Refresh", "20");

This idea seemed good for me. But the article is 7 years old. Plus at comments section a user complaints that this won't work if the page is minimized and I am worried that the same happens when my pages tab is not active.

I would like to know these things

  1. Whether the refresh method will work for my scenario , even if the page is minimized?
  2. Are there any other methods that could increase session time out that overrides IIS timeout setting?
  3. Also I read some questions in Stack Overflow where the answers state that the IIS session timeout is for clasic ASP pages. Then why is not my extended timeout not firing?

解决方案

Firstly, I would like to confirm whether this assumption is right.

Yes, this assumption is absolutely right in case you are using in-memory session state mode. In this case the session is stored in memory and since IIS could tear down the AppDomain under different circumstances (period of inactivity, CPU/memory tresholds are reached, ...) the session data will be lost. You could use an out-of-process session state mode. Either StateServer or SQLServer. In the first case the session is stored in the memory of a special dedicated machine running the aspstate Windows service and in the second case it is a dedicated SQL Server. The SQL Server is the most robust but obviously the slowest.

1) Whether the refresh method will work for my scenario , even if the page is minimized?

The hidden iframe still works to maintain the session alive but as I said previously there might be some conditions when IIS unloads the application anyway (CPU/memory tresholds are reached => you could configure this in IIS as well).

2) Are there any other methods that could increase session time out that overrides IIS timeout setting?

The previous method doesn't increase the session timeout. It simply maintains the session alive by sending HTTP requests to the server at regular intervals to prevent IIS from bringing the AppDomain down.

3) Also I read some questions in Stack Overflow where the answers state that the IIS session timeout is for clasic ASP pages. Then why is not my extended timeout not firing?

There is no such thing as IIS session timeout. The session is an ASP.NET artifact. IIS is a web server that doesn't know anything about sessions.

Personally I don't use sessions in my applications. I simply disable them:

<sessionState mode="Off"></sessionState>

and use standard HTTP artifacts such as cookies, query string parameters, ... to maintain state. I prefer to persist information in my backend and retrieving it later using unique ids instead of relying on sessions.

这篇关于增加会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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