简体   繁体   English

为什么我的 session 结束了?

[英]Why is my session ending?

I have an ASP.NET web application I'm running with VS2010 that has session timeout configured for 20 minutes.我有一个 ASP.NET web 应用程序我正在使用 VS2010 运行,它的 session 超时配置为 20 分钟。
I leave a page running that does an ajax call every 2 minutes and has a defibrillator implemented.我留下一个页面运行,每 2 分钟调用一次 ajax 并安装了除颤器 With this setup, the session should never expire;使用此设置,session 永远不会过期; and yet I find that 20 minutes later my session is still ending.但我发现 20 分钟后我的 session 仍在结束。

Does anybody know why that happens?有人知道为什么会这样吗? And more importantly, can anybody tell me how to make sure the session never expires when the user is in that page?更重要的是,谁能告诉我当用户在该页面时如何确保 session 永不过期?


EDIT: I changed the defibrillator so it now executes this code in javascript: setTimeout("location.href = '/Defibrillator.aspx?nocache=" + Math.floor(Math.random()*100000000001) + "';",60000);编辑:我更改了除颤器,因此它现在在 javascript 中执行此代码: setTimeout("location.href = '/Defibrillator.aspx?nocache=" + Math.floor(Math.random()*100000000001) + "';",60000);
Still the same, so it's not a cache issue.还是一样,所以这不是缓存问题。
I'm running the site from VS directly (via the Debug "play" button), so it shouldn't be sharing an Application Pool, right?我直接从 VS 运行站点(通过调试“播放”按钮),所以它不应该共享应用程序池,对吗?

Have you verified that the javascript is getting executed?您是否确认 javascript 正在执行? Check your access logs to see if the request is there.检查您的访问日志以查看请求是否存在。

Also inspect your cookies - I'd suspect that perhaps the session cookie is not getting updated, so you may need to reload the page occasionally in order to refresh it.还要检查您的 cookies - 我怀疑 session cookie 可能没有更新,因此您可能需要偶尔重新加载页面以刷新它。

Update: From the comments, it sounds like the session cookie as stored by the browser is not getting refreshed.更新:从评论中,听起来浏览器存储的 session cookie 没有被刷新。 I'd suggest either reloading the page periodically, and perhaps changing the session timeout.我建议定期重新加载页面,或者更改 session 超时。 You'll have to balance the two depending on the usage patterns of the app.您必须根据应用程序的使用模式来平衡两者。

In the end I had to resort to adding an autosave feature using ajax.最后,我不得不求助于使用 ajax 添加自动保存功能。
It's a sad day when StackOverflow can't give me an answer:( StackOverflow 无法给我答案,这是悲伤的一天:(


EDIT: I finally found out what was causing the problem... it turned out that in some place in the masterpage the code was calling a rather obscure method that enforced a fixed timeout... so it wasn't anything that you could have helped me with.编辑:我终于找到了导致问题的原因......原来在母版页的某个地方,代码正在调用一个相当模糊的方法,该方法强制执行固定超时......所以它不是你可以拥有的任何东西帮了我。 Sorry about that.对于那个很抱歉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM