2014-09-01 89 views

回答

0

有没有简单的方法来实现它,但我认为SignalR类技术将帮助你实现这个http://www.asp.net/signalr。否则,请在您的服务器端写入轮询ajax调用,并在登录后将此代码保存在主页面中。一旦服务器端指示用户需要注销,显示警告框并重定向到注销页面。

使用JavaScript定时器每5或10秒调用一次该方法。

   $.ajax({ 
        url : 'DoWeNeedToLogout.ashx', 
        type : 'GET', 
        success : function(result) { 
           if(result == "YES") 
             alert('We are about to logut'); 
             window.location = 'logoutpage.aspx'; 
          } 
       }); 

简单的创建普通HTTP处理程序

    public class DoWeNeedToLogout : IHttpHandler { 

         public void ProcessRequest(HttpContext context) { 
           // Do some logic here and return 
          if(OK) 
           context.Response.Write("YES"); 
          } 
        }