如何在ASP.NET MVC3应用程序中增加会话持续时间

问题描述:

大家好,



我通过MCC3设计模式开发了一个问题应用程序。



用户通过表单登录。然后我在会话中保留它的信息。但它很快结束(大约10分钟。)有超过100个问题,所以时间不够。有什么办法可以增加吗?



我试过的东西。



编辑的网页配置。



Hello everyone,

I have developed a questionare application via MCC3 design pattern.

User logins via form. Then I keep it's infos in a session. But it ends very quickly (approximately 10 minutes. ) There are over 100 questiones so time is not enough. Is there any way to increase that?

Things that I tried.

edited web config.

<system.web>
    <sessionState mode="InProc" timeout="30" />
  </system.web>





编辑的应用配置。



(再写一个方法来管理sessin状态和超时)



edited app config.

(write one more method to manage sessin state and timeout)

你不应该扩展会话 - 每个用户实例都会增加服务器上的内存使用量,在会议结束前不能处理。请参阅MSDN: https://msdn.microsoft.com/en-us/ library / ms525473(v = vs.90).aspx [ ^ ]

请记住,每次客户端与服务器通信时,它都会重置会话超时 - 因此,如果您正在运行出来,这是因为服务器可以告诉我什么都没发生!



如果您遇到客户端会话过期问题,那么我强烈建议您改为使用Cookies - 让会话自然死亡。
You should not extend the session - each user instance increases the memory usage on teh server, which can't be disposed of until the session ends. See MSDN: https://msdn.microsoft.com/en-us/library/ms525473(v=vs.90).aspx[^]
And bear in mind that each time the client communicates with the server, it resets the Session timeout - so if you are running out, it's because there is nothing happening as far as the server can tell!

If you are having problems with client session expiry, then I'd strongly suggest that you use Cookies instead - and let the session die a natural death.