如何在会话即将在弹出窗口中过期时向用户显示消息

问题描述:

我想在会话即将到期时向用户显示弹出窗口并在用户点击确定时重定向到用户...怎么做?... plz help ...

i want to show popup to user when session is about to expire and redirect to user when he clicks ok...how to do it?...plz help...

Hai

只需使用aleart消息显示时间到期,试试这个,请在​​MVC4中添加此javascript查看MasterPage,然后只有它可以在所有子页面上工作,你可以在每个页面也是如此,但是母版页是常见的,所以最好添加到母版页。这里等待15分钟,你可以改变你的到期时间



Hai
Just use aleart message to show time expiry,Try this,pls add this javascript in MVC4 View MasterPage,then only it work all child page,u can add this in each page also,but master page is common so better to add in master page.Here time wait for 15 mins,u can change ur expiry time

<script type="text/javascript">



               var logoutUser = false;
               var timeoutHnd = null;
               var logouTimeInterval = 15 * 60 * 1000; // 15 mins
               function onuser_activite() {
                   if (logoutUser) {
                       ;
                   }
                   else {
                       ResetLogOutTimer();

                   }
               }
               function OnTimeoutReached() {
                   logoutUser = true;
                   alert("You have been automatically Log Off from the system !");
                   window.location.href = "Logout.aspx";

               }
               function ResetLogOutTimer() {
                   clearTimeout(timeoutHnd);
                   // set new timer
                   timeoutHnd = setTimeout('OnTimeoutReached();', logouTimeInterval);
               }


               document.body.onclick = onuser_activite;
               timeoutHnd = setTimeout('OnTimeoutReached();', logouTimeInterval);
           </script>