Saturday, March 31, 2012

Session Times Out.... Navigate to Login Page

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
AmithYou 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"
<AmithSin@.hotmail.com> 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
>
Amith Singh wrote:

> When the sessions times out I would like to take the user to the login pag
e.
> Currently even though session times out user will come to know only when h
e
> 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
DoDotNet@.Gmail.com
www.RutgerSmit.com
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
DoDotNet@.Gmail.com
www.RutgerSmit.com
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" <DoDotNet@.gmail.com> wrote in message
news:10jk7k75fscpdbb@.corp.supernews.com...
> Rutger Smit wrote:
>
> 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
> DoDotNet@.Gmail.com
> www.RutgerSmit.com
Greg Burns wrote:

> I tried doing something like this before. I added some client side code o
n
> 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
>
>
>
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
DoDotNet@.Gmail.com
www.RutgerSmit.com
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*100
0)">
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
> DoDotNet@.Gmail.com
> www.RutgerSmit.com
Greg Burns wrote:
> I would think if I redirected using HTTP_REFERER header value that it woul
d
> 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 onlin
e
> 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*100
0)">
> What would be great is if there was someway to reset the timer on every po
st
> 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
DoDotNet@.Gmail.com
www.RutgerSmit.com
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
> DoDotNet@.Gmail.com
> www.RutgerSmit.com

0 comments:

Post a Comment