且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用ASP.NET GenericHandlers当ASP.NET管理会话超时

更新时间:2023-12-04 16:56:34

我们针对这种情况通过一个稍微不同的方法。而不是试图让所有的jQuery的调用处理这种错误情况,我们已经实现了使用JavaScript客户端上的并行超时系统。 ASP.NET会话前一分钟将超时,我们就弹出一个对话框上的浏览器向用户发出警告:你已经没有什么活动,并即将被注销。点击这里继续登录。我们包括一个小倒计时对话框也研究。如果他们点击保持登录状态,我们发送另一个jQuery的调用服务器复位会话超时。

We address this situation by a slightly different approach. Instead of trying to make all the jQuery calls deal with this kind of error condition, we have implemented a parallel timeout system on the client using javascript. A minute before the ASP.NET Session would time out, we pop up a dialog on the browser to warn the user "You have been inactive and are about to be logged out. Click here to remain logged in." We included a little countdown in the dialog also. If they click to stay logged in, we send another jQuery call to the server to reset the session timeout.

因此​​,除非用户已禁用JavaScript(在这种情况下,应用程序不反正工作),没有一种可能性,即我们做一个jQuery的电话后,ASP.NET会话超时。

So, unless the user has javascript disabled (in which case, the app doesn't work anyway), there is not a possibility that we make a jQuery call after the ASP.NET session has timed out.