Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Session Timeout Alert Message and Redirect to login page.

Session Timeout Alert Message and Redirect to login page.

Scheduled Pinned Locked Moved ASP.NET
javascripthelpworkspace
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dsrao
    wrote on last edited by
    #1

    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

    T 1 Reply Last reply
    0
    • D dsrao

      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

      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      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

      D 1 Reply Last reply
      0
      • T ToddHileHoffer

        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

        D Offline
        D Offline
        dsrao
        wrote on last edited by
        #3

        Thank you so much...

        Thanks & Regards Rao

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups