Session Timeout Alert Message and Redirect to login page.
-
Hi All, When user navigate pages if the session expires I want to show alert message and redirect login page. I written code for above reqruirement it is loging out but does not show message. My code as follows default.aspx.cs protected void Page_Load(object sender, EventArgs e) { Common comm = new Common(); if (Session[USER_CONTEXT] != null) { // do something... } else { // I want show javascript alert message to the user then click OK , redirect to logOutURL comm.LogoffTohome(); return; } } Common.cs public void LogoffTohome() { string Jscript = "javascript:alert('Your session is over')"; ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "SessionTimeout", Jscript, true); Session.Abandon(); HttpContext.Current.Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["LogoutUrl"].ToString()); } I really appreciate if your help... Thanks Rao
Thanks & Regards Rao
-
Hi All, When user navigate pages if the session expires I want to show alert message and redirect login page. I written code for above reqruirement it is loging out but does not show message. My code as follows default.aspx.cs protected void Page_Load(object sender, EventArgs e) { Common comm = new Common(); if (Session[USER_CONTEXT] != null) { // do something... } else { // I want show javascript alert message to the user then click OK , redirect to logOutURL comm.LogoffTohome(); return; } } Common.cs public void LogoffTohome() { string Jscript = "javascript:alert('Your session is over')"; ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "SessionTimeout", Jscript, true); Session.Abandon(); HttpContext.Current.Response.Redirect(System.Configuration.ConfigurationManager.AppSettings["LogoutUrl"].ToString()); } I really appreciate if your help... Thanks Rao
Thanks & Regards Rao
Try firefox and firebug to debug javascript. Or vs 2008. You don't need change string Jscript = "javascript:alert('Your session is over')"; to string Jscript = "alert('Your session is over'); window.location('" + System.Configuration.ConfigurationManager.AppSettings["LogoutUrl"].ToString() + "'); "; You should redirect from javascript after the alert.
I didn't get any requirements for the signature
-
Try firefox and firebug to debug javascript. Or vs 2008. You don't need change string Jscript = "javascript:alert('Your session is over')"; to string Jscript = "alert('Your session is over'); window.location('" + System.Configuration.ConfigurationManager.AppSettings["LogoutUrl"].ToString() + "'); "; You should redirect from javascript after the alert.
I didn't get any requirements for the signature