如何同步 JS 超时和 ASP.NET 会话超时?
好的。我无法真正解决我想要的问题 - 因此,如果您可以,请告诉我如何:
我有一个页面,每次点击都有对我的服务器的 ajax 调用(因此,ASP 扩展了会话)
我有 ASP.NET 会话设置为 Xmin。我希望当 X+1 分钟到期时,我有到期页面。我所做的是设置JS计时器每隔x+1分钟验证一次以查看会话是否过期(问题是JS和ASP会话超时不同步)
我怎样才能使它们同步?
Ok. I can't really solve what I want - so if you can please advise me on how to:
I have a page of each every click has ajax call to my server (hence, the ASP extends the session)
I have ASP.NET session set to Xmin. I want when X+1 min expires, I have expiration page. what I did was to set the JS timer to validate every x+1min to see if the session expired (the problem is that the JS and the ASP session timeouts are not synced)
how can I make them be synced?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每次你进行ajax调用时都会再次重置你的超时。
这样它们就会同步...
every time you make an ajax call reset your timeout agian.
so they will be synced...
我说你不能绝对同步它们,因为它们运行在两台不同的计算机上,你无法控制其中的一台。因此,最好找到其他方法来完成您尝试的事情。
这里有类似的链接。
http://forums.asp.net/p/1207721/3094847.aspx
链接
http://www.codeproject.com/KB/ scripting/Session_Timeout.aspx
获取ASP.NET 会话上次访问时间(或超时时间)
I say that you can not absolute synchronized them because they run on 2 different computer that you can not control the one of them. So is better find other way to do what you try.
Here are similar links.
http://forums.asp.net/p/1207721/3094847.aspx
Link
http://www.codeproject.com/KB/scripting/Session_Timeout.aspx
Get ASP.NET Session Last Access Time (or Time-to-Timeout)