I have made session time setting in web config as
<sessionState mode="InProc" cookieless="true" timeout="1" />
now i m checking here as..
Protected Overrides Sub OnActionExecuting(filterContext As ActionExecutingContext)
If HttpContext.Session IsNot Nothing Then
If HttpContext.Session.IsNewSession Then
If Not filterContext.HttpContext.Request.IsAjaxRequest() Then
Dim sessionCookie As String = HttpContext.Request.Headers("Cookie")
If (sessionCookie IsNot Nothing) AndAlso (sessionCookie.IndexOf("ASP.NET_SessionId") >= 0) Then
Dim viewData = filterContext.Controller.ViewData
filterContext.HttpContext.Response.StatusCode = 504
HttpContext.Response.Redirect("~/Case/TimeOut")
End If
End If
End If
End If
On
HttpContext.Response.Redirect("~/Case/TimeOut")
i m calling partial view to call alert , of session end like this
<script>
var sessionTimeoutWarning = "You Session is going to finish in one minute.";
var sessionTimeout = "<%= Session.Timeout %>";
var timeOnPageLoad = new Date();
var sessionWarningTimer = null;
var redirectToWelcomePageTimer = null;
var sessionWarningTimer = setTimeout('SessionWarning()', parseInt(sessionTimeoutWarning) * 60 * 1000);
var redirectToWelcomePageTimer = setTimeout('RedirectToWelcomePage()',parseInt(sessionTimeout) * 60 * 1000);
function SessionWarning() {
var minutesForExpiry = (parseInt(sessionTimeout) - parseInt(sessionTimeoutWarning));
var message = "Your session will expire in another " + minutesForExpiry + " mins. Do you want to extend the session?";
answer = confirm(message);
if(answer)
{
var img = new Image(1, 1);
img.src = '@Url.Action("CaseManage","Case")'; @*?date=' + escape(new Date());*@
//Clear the RedirectToWelcomePage method
if (redirectToWelcomePageTimer != null) {
clearTimeout(redirectToWelcomePageTimer);
}
timeOnPageLoad = new Date();
sessionWarningTimer = setTimeout('SessionWarning()', parseInt(sessionTimeoutWarning) * 60 * 1000);
//To redirect to the welcome page
redirectToWelcomePageTimer = setTimeout('RedirectToWelcomePage()',parseInt(sessionTimeout) * 60 * 1000);
}
//*************************
//Even after clicking ok(extending session) or cancel button, if the session time is over. Then exit the session.
var currentTime = new Date();
//time for expiry
var timeForExpiry = timeOnPageLoad.setMinutes(timeOnPageLoad.getMinutes() + parseInt(sessionTimeout));
//Current time is greater than the expiry time
if(Date.parse(currentTime) > timeForExpiry)
{
alert("Session expired. You will be redirected to welcome page");
window.location = "@Url.Action("CaseManage","Case")";
}
//**************************
}
//Session timeout
function RedirectToWelcomePage(){
alert("Session expired. You will be redirected to welcome page");
window.location = "@Url.Action("Index","LogOn")";
}
</script>
.
what does i want, when i got alert, that the, session is going to end, on clicking the, ok button, the, session extends.
Please Help...