ASP.NET - Session Time Out

霸气de小男生 提交于 2019-12-11 02:28:37

问题


In the web.config file for my application, in the <sessionState> section I have set timeout="60" (in minutes), but session state variables in my application seem to be expiring in about 1 minutes. Any idea what could cause this?


回答1:


Yes.

Session timeouts are also specified and controlled by IIS (although there is overlap ofcourse). In IIS 6.0 you also need to check the following places in IIS manager (properties of Virtual directory):

  • ASP.net tab > Edit configuration > Authentication tab > Cookie timeout
  • ASP.net tab > Edit configuration > State management tab > Session timeout

Setting all these to the same value, fixed the issue for me.

edit: Apparently the previously listed first option, had nothing to do with it. That means, that the first of the two options is now the place for you to fix your session timeout. It's probably not your session timing out, but the authentication expiring.

Or another possibility is that the worker process is restarted, or the application is restarted. Also things to look into.




回答2:


If you are storing session state "in proc" then every time the app pool recycles you can loose session (this can happen a lot on a server with low memory). You could try storing session state "out of proc" using State Server or SQL Server.

See PRB: Session Data Is Lost When You Use ASP.NET InProc Session State Mode



来源:https://stackoverflow.com/questions/1606167/asp-net-session-time-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!