Session Times Out.... Navigate to Login Page

Discussion in 'ASP .Net' started by Amith Singh, Sep 4, 2004.

  1. Amith Singh

    Amith Singh Guest

    When the sessions times out I would like to take the user to the login page.
    Currently even though session times out user will come to know only when he
    clicks on the screen. How to direct the user automatically to login page
    once the session times out. I am using .Net Framework 1.1. and IIS 5
    Amith
    Amith Singh, Sep 4, 2004
    #1
    1. Advertising

  2. Amith Singh

    Scott Allen Guest

    You could force the browser to refresh after a set amount of time:

    Response.AppendHeader("Refresh", (Session.Timeout * 60 +
    10).ToString() + "; URL=Login.aspx");

    This will calculate the time to refresh using the Session timeout
    value on the server (specified in minutes).

    HTH,

    --
    Scott
    http://www.OdeToCode.com

    On Sat, 4 Sep 2004 11:14:52 -0700, "Amith Singh"
    <> wrote:

    >When the sessions times out I would like to take the user to the login page.
    >Currently even though session times out user will come to know only when he
    >clicks on the screen. How to direct the user automatically to login page
    >once the session times out. I am using .Net Framework 1.1. and IIS 5
    >Amith
    >
    Scott Allen, Sep 4, 2004
    #2
    1. Advertising

  3. Amith Singh

    Rutger Smit Guest

    Amith Singh wrote:

    > When the sessions times out I would like to take the user to the login page.
    > Currently even though session times out user will come to know only when he
    > clicks on the screen. How to direct the user automatically to login page
    > once the session times out. I am using .Net Framework 1.1. and IIS 5
    > Amith
    >
    >


    Run a cli9ent sided time somwhere somehow and when I reaches the 20
    minutes (default session timeout setting) you do something like a popup,
    redirect, etc.

    --

    //Rutger


    www.RutgerSmit.com
    Rutger Smit, Sep 4, 2004
    #3
  4. Amith Singh

    Rutger Smit Guest

    Rutger Smit wrote:

    > Amith Singh wrote:
    >
    >
    > Run a cli9ent sided time somwhere somehow and when I reaches the 20
    > minutes (default session timeout setting) you do something like a popup,
    > redirect, etc.
    >


    Where was my mind?
    Here the intended answer:


    Run a clientsided script somewhere somehow and when it reaches the 20
    minutes (default session timeout setting) you do something like a popup,
    redirect, etc.

    --

    //Rutger


    www.RutgerSmit.com
    Rutger Smit, Sep 4, 2004
    #4
  5. Amith Singh

    Greg Burns Guest

    I tried doing something like this before. I added some client side code on
    page load to redirect after 20 minutes or whatever. Problem was a user
    could stay on the same page for more than 20 minutes and keep the session
    alive by posting back to itself. But when the client side script hit 20
    minutes from the initial page load... whoops... times up.

    I would like to see a solution myself.

    Greg

    "Rutger Smit" <> wrote in message
    news:...
    > Rutger Smit wrote:
    >
    > > Amith Singh wrote:
    > >
    > >
    > > Run a cli9ent sided time somwhere somehow and when I reaches the 20
    > > minutes (default session timeout setting) you do something like a popup,
    > > redirect, etc.
    > >

    >
    > Where was my mind?
    > Here the intended answer:
    >
    >
    > Run a clientsided script somewhere somehow and when it reaches the 20
    > minutes (default session timeout setting) you do something like a popup,
    > redirect, etc.
    >
    > --
    >
    > //Rutger
    >
    >
    > www.RutgerSmit.com
    Greg Burns, Sep 4, 2004
    #5
  6. Amith Singh

    Rutger Smit Guest

    Greg Burns wrote:

    > I tried doing something like this before. I added some client side code on
    > page load to redirect after 20 minutes or whatever. Problem was a user
    > could stay on the same page for more than 20 minutes and keep the session
    > alive by posting back to itself. But when the client side script hit 20
    > minutes from the initial page load... whoops... times up.
    >
    > I would like to see a solution myself.
    >
    > Greg
    >
    >>Where was my mind?
    >>Here the intended answer:
    >>
    >>
    >>Run a clientsided script somewhere somehow and when it reaches the 20
    >>minutes (default session timeout setting) you do something like a popup,
    >> redirect, etc.
    >>
    >>--
    >>
    >>//Rutger
    >>
    >>
    >>www.RutgerSmit.com

    >
    >
    >



    Maybe you can make the script a little bit more intelligent.
    On the client: do the time thing that redirects after 20 minutes.
    Redirect the client to a special page that check wheter the session is
    still alive or not. If it is, no broblem, redirect the client to the
    HTTP_REFERER header value. If the session has expired, redir to login page.

    --

    //Rutger


    www.RutgerSmit.com
    Rutger Smit, Sep 4, 2004
    #6
  7. Amith Singh

    Greg Burns Guest

    I would think if I redirected using HTTP_REFERER header value that it would
    cause IsPostBack to False again, plus viewstate would not be retained. I
    would be as if it was the first time visiting the page.

    Here is some code I was playing with that I found while visiting the online
    ticket ordering at sixflags.com.

    function WarnUserTimeout()
    {
    alert('Your session has expired. You are being redirected to the park
    selection page.')
    window.location.href = "tickets_parkselect.asp";
    }

    <body OnLoad="window.setTimeout('WarnUserTimeout()',10*60*1000)">

    What would be great is if there was someway to reset the timer on every post
    back...

    Greg

    > Maybe you can make the script a little bit more intelligent.
    > On the client: do the time thing that redirects after 20 minutes.
    > Redirect the client to a special page that check wheter the session is
    > still alive or not. If it is, no broblem, redirect the client to the
    > HTTP_REFERER header value. If the session has expired, redir to login

    page.
    >
    > --
    >
    > //Rutger
    >
    >
    > www.RutgerSmit.com
    Greg Burns, Sep 5, 2004
    #7
  8. Amith Singh

    Rutger Smit Guest

    Greg Burns wrote:
    > I would think if I redirected using HTTP_REFERER header value that it would
    > cause IsPostBack to False again, plus viewstate would not be retained. I
    > would be as if it was the first time visiting the page.
    >
    > Here is some code I was playing with that I found while visiting the online
    > ticket ordering at sixflags.com.
    >
    > function WarnUserTimeout()
    > {
    > alert('Your session has expired. You are being redirected to the park
    > selection page.')
    > window.location.href = "tickets_parkselect.asp";
    > }
    >
    > <body OnLoad="window.setTimeout('WarnUserTimeout()',10*60*1000)">
    >
    > What would be great is if there was someway to reset the timer on every post
    > back...
    >
    > Greg
    >
    >
    >




    'reset the timer on every post back'
    It does since it's JavaScript and thus running client sided.
    If you're using frames you have to do some cross frame scripting with a
    function that sets the timer to zero.

    --

    //Rutger


    www.RutgerSmit.com
    Rutger Smit, Sep 6, 2004
    #8
  9. Amith Singh

    Greg Burns Guest

    You know, you're right.

    I just retested it to make sure I wasn't making this up, but couldn't
    duplicate it. I definately had a problem with this very issue when I first
    attempted this. I will need to take a second look.

    Thanks,
    Greg

    > 'reset the timer on every post back'
    > It does since it's JavaScript and thus running client sided.
    > If you're using frames you have to do some cross frame scripting with a
    > function that sets the timer to zero.
    >
    > --
    >
    > //Rutger
    >
    >
    > www.RutgerSmit.com
    Greg Burns, Sep 6, 2004
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Green
    Replies:
    3
    Views:
    524
    Alvin Bruney
    Jan 10, 2004
  2. =?Utf-8?B?RWFybCBUZWlncm9i?=

    Does session cookie persist when after session times out?

    =?Utf-8?B?RWFybCBUZWlncm9i?=, Jul 28, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    592
    Mike Newton
    Jul 28, 2004
  3. Rotsey
    Replies:
    0
    Views:
    284
    Rotsey
    Jan 15, 2007
  4. =?Utf-8?B?U00=?=
    Replies:
    0
    Views:
    450
    =?Utf-8?B?U00=?=
    Feb 27, 2007
  5. VSK
    Replies:
    3
    Views:
    332
    Softwaremaker
    Oct 2, 2003
Loading...

Share This Page