Here a javascript solution for detecting session expire.
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<style type="text/css">
.message
{
border: 1px solid #CCCCCC;
position: absolute;
width: 400px;
border: 1px solid #c93;
background: #ffc;
padding: 5px;
left: 0px;
top: -170px;
}
</style>
<script language="javascript" type="text/javascript">
function ShowAlert() {
//get the height and width of the screen
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
//get the height and width of the message box
var popupHeight = $("#TimeoutMessage").height();
var popupWidth = $("#TimeoutMessage").width();
//show the message box
$("#TimeoutMessage").animate({
"top": windowHeight / 2 - popupHeight / 2,
"left": windowWidth / 2 - popupWidth / 2
}, 1000);
//close the message box when cross red image is clicked
$("#close_message").click(function() {
$("#TimeoutMessage").fadeOut("slow");
});
setTimeout('Redirect()', 300000); //15 minutes in milliseconds
}
function Redirect() {
window.location = "../../logout.aspx";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div id="TimeoutMessage" class="message">
<p>
You will be logged out due to inactivity in 5 minutes.<br /><br />
Please refresh this page, or click on an action to refresh your session.</p>
</div>
</form>
<script language="javascript" type="text/javascript">
$(document).ready(function () {
setTimeout('ShowAlert()', <%=((Session.Timeout * 60) * 1000) - 300000 %>);
});
</script>
</body>
</html>
Subscribe to:
Post Comments (Atom)
I Built a New Kind of Number Puzzle Game (And You Can Play It Free)
For a long time, I wanted to play a mobile puzzle game that felt genuinely strategic—something that required real brainpower, skipped the a...
-
Microsoft Graph API provides powerful capabilities to interact with Microsoft 365 services. In this guide, we’ll explore how to create calen...
-
Microsoft Graph API is a powerful tool that allows developers to access a wide range of Microsoft 365 services, including Outlook and Calend...
-
When you already have IIS running then you may not be able to run WAMP Server at Localhost. You need to shutdown IIS in order to run WAMP Se...
NIce Blog , :)
ReplyDeleteThanks
ReplyDelete