I am creating web application using .Net framework 3.5, I implemented asp.net membership (Forms Authentication), Now, What i want is when user session state is inactive then redirect page to Lockscreen.aspx and then user will enter details and continue work. After lot of search I have got something is
Web config
<sessionState mode="InProc" timeout="2"/>
<authentication mode="Forms">
<forms defaultUrl="~/Pages/Default.aspx"
loginUrl="~/Pages/Login.aspx" timeout="2"
/>
</authentication>
I am configuring session timeout as when session timeout then user should get alert and if user doesn't respond then redirect to lockscreen.aspx
Default.aspx
function SessionExpireAlert(timeout) {
var seconds = timeout / 1000;
alert(seconds);
document.getElementsByName("secondsIdle").innerHTML = seconds;
document.getElementsByName("seconds").innerHTML = seconds;
setInterval(function () {
seconds--;
document.getElementById("seconds").innerHTML = seconds;
document.getElementById("secondsIdle").innerHTML = seconds;
}, 1000);
setTimeout(function () {
$find("mpeTimeout").show();
}, timeout - 20 * 1000);
setTimeout(function () {
window.location = "LockScreen.aspx";
}, timeout);
}
function ResetSession() {
window.location = window.location.href;
}
Defualt.aspx.cs
Response.Cache.SetCacheability(HttpCacheability.NoCache);
if (!this.IsPostBack)
{
Session["Reset"] = true;
Configuration config = WebConfigurationManager.OpenWebConfiguration("~/Web.Config");
SessionStateSection section = (SessionStateSection)config.GetSection("system.web/sessionState");
int timeout = (int)section.Timeout.TotalMinutes * 1000 * 60;
ClientScript.RegisterStartupScript(this.GetType(), "SessionAlert", "SessionExpireAlert(" + timeout + ");", true);
}
Now problem is when user session is still active session timeout alert occur's . I don't want that to be happen .Alert should appear when session is expired/timeout.