Session Timeout ASP.Net

不羁的心 提交于 2019-12-29 08:13:30

问题


I'm trying to increase the timeout on all sessions. The site is hosted with Godaddy, and it is written in Flash (client side of course) and asp.net on the backend. I've added this to my web.config,

<sessionState timeout="720">

</sessionState>

Is that really all that I need to do? I'd prefer to not let sessions expire ever, but I'm sure that the server needs to reclaim that memory at some point...I'm not storing anything in the session, really, just using it to track users' progress through the site, and if a user is logged in or not.

Thanks for any pointers...all the documentation seems deceptively simple, and it kind of makes me nervous...


回答1:


Yup! As in; Yes, that's the only thing you need to do...

To get "never ending timeouts" you'd have to create a background HTTP request (which will transmit the session cookie) back to the server every 719 minute though. Though theoretically then you'd also have to have "Out of Process" sessions using e.g. some sort of database or something...

Or you could roll your own session handler, I think APS.NET have support for this through using some sort of adapter pattern or something, but I am not sure. Then you could have a "truly" never ending session...




回答2:


If you are using Forms Authentication you will also need to set the Forms Authentication Timeout in your web.config

Example:

<authentication mode="Forms">
  <forms
    name=".ASPXAUTH"
    loginUrl="/Home/Default.aspx"
    defaultUrl="/Dashboard/Default.aspx"
    protection="All"
    timeout="30"
    slidingExpiration="true"
  />
</authentication>


来源:https://stackoverflow.com/questions/316172/session-timeout-asp-net

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