How to redirect to login page automatically, after session time out.

    Question by:
    On

    Topics:

    How to redirect to login page automatically, after session time out?
    In my web application, user logs in in the application, after a certain time (30 mins) session times out and login page appears only AFTER user action.
    I would like to redirect the user back to the login screen automatically (before user performs any action) after session has timed out.

    Your suggestions will be greatly appreciated.

    I used following code in pagerender of masterpage.
     
     HttpContext.Current.Response.AppendHeader("Refresh", Convert.ToString(((HttpContext.Current.Session.Timeout * 60) - 5)) + "; Url=homepage.aspx")
     
    Also, i have Session_Start/Session_end in global.asax.
    
                                    
    1:
    2:
    3:
    4:
    5:
    

    Select allOpen in new window

    Good Question?
    0
     

    ?

    The member who asked this question verified this comment provided the solution that solved their problem.

    Accepted Solution on 2008-05-14 at 05:49:36ID: 21563505

    Javascript:
    function timeout(){window.location = "http://google.com"}

    call it in your html:
    <body onload="setTimeout('timeout()', 5000)">

    But you would still have to put this into every page... not sure how you are going to accomplish this without masterpages.

    Top Expert Contributor

    Essential articles and videos from the Experts

    More valuable questions with Expert answers

    201511-LO-Qu-074

    Extend your technology team with the Experts Exchange community.

    — trusted by —

    Who answers my questions?Our community has technology experts around the world.

    Jacques Bourgeois (James Burger)

    2

    Articles

    2,049

    Solutions

    Expert in:

    • .NET Programming
    • Visual Basic.NET
    • C#
    • MS Development-Other
    • ASP.NET

    Fernando Soto

    5,013

    Solutions

    Expert in:

    • .NET Programming
    • Visual Basic.NET
    • C#
    • ASP.NET
    • Editors IDEs

    käµfm³d   👽

    9

    Articles

    7,460

    Solutions

    Expert in:

    • .NET Programming
    • C#
    • Visual Basic.NET
    • ASP.NET
    • Regular Expressions

    Lokesh B R

    205

    Solutions

    Expert in:

    • .NET Programming
    • ASP.NET
    • C#
    • Visual Basic.NET

    Alexandre Simões

    6

    Articles

    1,022

    Solutions

    Expert in:

    • .NET Programming
    • C#
    • JavaScript
    • Visual Basic.NET
    • ASP.NET

    Karrtik Iyer

    278

    Solutions

    Expert in:

    • .NET Programming
    • C#
    • Visual Basic.NET
    • ASP.NET
    • C++

    it_saige

    1,038

    Solutions

    Expert in:

    • .NET Programming
    • C#
    • Visual Basic.NET
    • ASP.NET
    • Active Directory

    Paweł Ciucias

    20

    Solutions

    gr8gonzo

    19

    Articles

    1,245

    Solutions

    Expert in:

    • PHP
    • MySQL Server
    • Apache Web Server
    • HTML
    • JavaScript

    RELATED TOPICS view all topics

    1. ASP.NET
      (122,126)
    2. C#
      (90,429)
    3. Visual Basic.NET
      (91,461)
    4. MS Development-Other
      (48,696)
    5. Editors IDEs
      (25,097)
    6. Visual Basic Classic
      (162,830)
    7. MS SQL Server
      (154,732)
    8. MS SQL Server 2005
      (71,599)
    9. Programming-Other
      (51,631)
    10. JavaScript
      (117,369)