Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > RenewSession State Before Expiration In .Net 1.1

Reply
Thread Tools

RenewSession State Before Expiration In .Net 1.1

 
 
WhiskeyRomeo
Guest
Posts: n/a
 
      01-15-2008
The below appears to be a partial answer to my problem but I don't to keep
sessions alive simply because a user has wondered off to do something else.
Session timeout is set to the standard 30 minutes.

KEEPALIVE.aspx has:
private void Page_Load(object sender, System.EventArgs e)
{
Response.AddHeader("Refresh",8000);
}
MyRegPage.aspx has:
<IFRAME id=KEEPALIVE src="KEEPALIVE.aspx"
frameBorder=no width=0 height=0 runat="server"></IFRAME>

I am not a JavaScript programmer but have some very basic skills, how can I
use this solution but add an alert button that pops up at the 17 minute mark
and if they click Ok the KeepAlive.aspx refreshes. If there is no response
(by the 20 minute mark) the alert box goes away and is replaced by one that
says "Your Session has timed out. Go to . . ."

wr
 
Reply With Quote
 
 
 
 
Alvin Bruney [ASP.NET MVP]
Guest
Posts: n/a
 
      01-17-2008
No, that's not a good approach. Think security, I open several hundred
connections and now since you allow me to keep those active sessions open,
I'll eventually cause your server to run out of memory. If the user walks
away, the session should time out otherwise, they need to be at the
computer - this long standing design makes sense for a number of different
reasons and you should stick to it. Having said that, I've done this as well
but set the app pool to recycle at midnight to 'somewhat' mitigate the
resource threat. I hope my rambling makes sense to you.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------



"WhiskeyRomeo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> The below appears to be a partial answer to my problem but I don't to keep
> sessions alive simply because a user has wondered off to do something
> else.
> Session timeout is set to the standard 30 minutes.
>
> KEEPALIVE.aspx has:
> private void Page_Load(object sender, System.EventArgs e)
> {
> Response.AddHeader("Refresh",8000);
> }
> MyRegPage.aspx has:
> <IFRAME id=KEEPALIVE src="KEEPALIVE.aspx"
> frameBorder=no width=0 height=0 runat="server"></IFRAME>
>
> I am not a JavaScript programmer but have some very basic skills, how can
> I
> use this solution but add an alert button that pops up at the 17 minute
> mark
> and if they click Ok the KeepAlive.aspx refreshes. If there is no
> response
> (by the 20 minute mark) the alert box goes away and is replaced by one
> that
> says "Your Session has timed out. Go to . . ."
>
> wr


 
Reply With Quote
 
 
 
 
WhiskeyRomeo
Guest
Posts: n/a
 
      01-17-2008
Yes, thanks for replying -- I know it is a bad approach hence the question
how can I use JavaScript to control it?

WR

"Alvin Bruney [ASP.NET MVP]" wrote:

> No, that's not a good approach. Think security, I open several hundred
> connections and now since you allow me to keep those active sessions open,
> I'll eventually cause your server to run out of memory. If the user walks
> away, the session should time out otherwise, they need to be at the
> computer - this long standing design makes sense for a number of different
> reasons and you should stick to it. Having said that, I've done this as well
> but set the app pool to recycle at midnight to 'somewhat' mitigate the
> resource threat. I hope my rambling makes sense to you.
>
> --
>
> Regards,
> Alvin Bruney [MVP ASP.NET]
>
> [Shameless Author plug]
> The O.W.C. Black Book, 2nd Edition
> Exclusively on www.lulu.com/owc $19.99
> -------------------------------------------------------
>
>
>
> "WhiskeyRomeo" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > The below appears to be a partial answer to my problem but I don't to keep
> > sessions alive simply because a user has wondered off to do something
> > else.
> > Session timeout is set to the standard 30 minutes.
> >
> > KEEPALIVE.aspx has:
> > private void Page_Load(object sender, System.EventArgs e)
> > {
> > Response.AddHeader("Refresh",8000);
> > }
> > MyRegPage.aspx has:
> > <IFRAME id=KEEPALIVE src="KEEPALIVE.aspx"
> > frameBorder=no width=0 height=0 runat="server"></IFRAME>
> >
> > I am not a JavaScript programmer but have some very basic skills, how can
> > I
> > use this solution but add an alert button that pops up at the 17 minute
> > mark
> > and if they click Ok the KeepAlive.aspx refreshes. If there is no
> > response
> > (by the 20 minute mark) the alert box goes away and is replaced by one
> > that
> > says "Your Session has timed out. Go to . . ."
> >
> > wr

>

 
Reply With Quote
 
Alvin Bruney [ASP.NET MVP]
Guest
Posts: n/a
 
      01-17-2008
I had code for this but I can't find it. Here's how I remember doing it.
Create a function that pops a message box. Capture the return value from the
message box click. Let's call that function A. Map your mouse move events to
another function, let's call that function B. Inside function B, you call
the javascript clearTimeout and reset the timer with a call to setTimeout.
When the user is at the computer working the mouse move events will keep
rescheduling the timer. Inside Function A, you call setTimeout with a
suitable time and pass in function A so that function A is called after the
time expires. If the mouse never moves, the timer will run out and the
function A will be called. Function A should ideally pop an alert box and
then redirect the user to a login page. The redirection happens after the
user clicks ok. If the user never comes back the message box remains.
Settimeout etc
http://www.elated.com/articles/javas...d-setinterval/

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------



"WhiskeyRomeo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Yes, thanks for replying -- I know it is a bad approach hence the question
> how can I use JavaScript to control it?
>
> WR
>
> "Alvin Bruney [ASP.NET MVP]" wrote:
>
>> No, that's not a good approach. Think security, I open several hundred
>> connections and now since you allow me to keep those active sessions
>> open,
>> I'll eventually cause your server to run out of memory. If the user walks
>> away, the session should time out otherwise, they need to be at the
>> computer - this long standing design makes sense for a number of
>> different
>> reasons and you should stick to it. Having said that, I've done this as
>> well
>> but set the app pool to recycle at midnight to 'somewhat' mitigate the
>> resource threat. I hope my rambling makes sense to you.
>>
>> --
>>
>> Regards,
>> Alvin Bruney [MVP ASP.NET]
>>
>> [Shameless Author plug]
>> The O.W.C. Black Book, 2nd Edition
>> Exclusively on www.lulu.com/owc $19.99
>> -------------------------------------------------------
>>
>>
>>
>> "WhiskeyRomeo" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > The below appears to be a partial answer to my problem but I don't to
>> > keep
>> > sessions alive simply because a user has wondered off to do something
>> > else.
>> > Session timeout is set to the standard 30 minutes.
>> >
>> > KEEPALIVE.aspx has:
>> > private void Page_Load(object sender, System.EventArgs e)
>> > {
>> > Response.AddHeader("Refresh",8000);
>> > }
>> > MyRegPage.aspx has:
>> > <IFRAME id=KEEPALIVE src="KEEPALIVE.aspx"
>> > frameBorder=no width=0 height=0 runat="server"></IFRAME>
>> >
>> > I am not a JavaScript programmer but have some very basic skills, how
>> > can
>> > I
>> > use this solution but add an alert button that pops up at the 17 minute
>> > mark
>> > and if they click Ok the KeepAlive.aspx refreshes. If there is no
>> > response
>> > (by the 20 minute mark) the alert box goes away and is replaced by one
>> > that
>> > says "Your Session has timed out. Go to . . ."
>> >
>> > wr

>>


 
Reply With Quote
 
WhiskeyRomeo
Guest
Posts: n/a
 
      01-18-2008
This is all well and good (you are keeping time on the client). But how is
the session state (on the server) kept alive when the use clicks OK on the
alert box button? Once a page loads and there is no post for 20 minutes, his
session should time out. So rather than keeping time via mouse movements, I
just want to keep time between loading of a page and between postbacks. The
alert box should pop up at least 3 minutes before session time expires.
Since I am not going to keep track of session time on the server, I am going
to assume it starts over on page load or on a post back -- like your
suggestion says -- and kept a timer on the client.

If the user clicks OK on the alert box, he should remain on the page he is
on and an invisible post back happens to keep the session alive.

WR

"Alvin Bruney [ASP.NET MVP]" wrote:

> I had code for this but I can't find it. Here's how I remember doing it.
> Create a function that pops a message box. Capture the return value from the
> message box click. Let's call that function A. Map your mouse move events to
> another function, let's call that function B. Inside function B, you call
> the javascript clearTimeout and reset the timer with a call to setTimeout.
> When the user is at the computer working the mouse move events will keep
> rescheduling the timer. Inside Function A, you call setTimeout with a
> suitable time and pass in function A so that function A is called after the
> time expires. If the mouse never moves, the timer will run out and the
> function A will be called. Function A should ideally pop an alert box and
> then redirect the user to a login page. The redirection happens after the
> user clicks ok. If the user never comes back the message box remains.
> Settimeout etc
> http://www.elated.com/articles/javas...d-setinterval/
>
> --
>
> Regards,
> Alvin Bruney [MVP ASP.NET]
>
> [Shameless Author plug]
> The O.W.C. Black Book, 2nd Edition
> Exclusively on www.lulu.com/owc $19.99
> -------------------------------------------------------
>
>
>
> "WhiskeyRomeo" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Yes, thanks for replying -- I know it is a bad approach hence the question
> > how can I use JavaScript to control it?
> >
> > WR
> >
> > "Alvin Bruney [ASP.NET MVP]" wrote:
> >
> >> No, that's not a good approach. Think security, I open several hundred
> >> connections and now since you allow me to keep those active sessions
> >> open,
> >> I'll eventually cause your server to run out of memory. If the user walks
> >> away, the session should time out otherwise, they need to be at the
> >> computer - this long standing design makes sense for a number of
> >> different
> >> reasons and you should stick to it. Having said that, I've done this as
> >> well
> >> but set the app pool to recycle at midnight to 'somewhat' mitigate the
> >> resource threat. I hope my rambling makes sense to you.
> >>
> >> --
> >>
> >> Regards,
> >> Alvin Bruney [MVP ASP.NET]
> >>
> >> [Shameless Author plug]
> >> The O.W.C. Black Book, 2nd Edition
> >> Exclusively on www.lulu.com/owc $19.99
> >> -------------------------------------------------------
> >>
> >>
> >>
> >> "WhiskeyRomeo" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> > The below appears to be a partial answer to my problem but I don't to
> >> > keep
> >> > sessions alive simply because a user has wondered off to do something
> >> > else.
> >> > Session timeout is set to the standard 30 minutes.
> >> >
> >> > KEEPALIVE.aspx has:
> >> > private void Page_Load(object sender, System.EventArgs e)
> >> > {
> >> > Response.AddHeader("Refresh",8000);
> >> > }
> >> > MyRegPage.aspx has:
> >> > <IFRAME id=KEEPALIVE src="KEEPALIVE.aspx"
> >> > frameBorder=no width=0 height=0 runat="server"></IFRAME>
> >> >
> >> > I am not a JavaScript programmer but have some very basic skills, how
> >> > can
> >> > I
> >> > use this solution but add an alert button that pops up at the 17 minute
> >> > mark
> >> > and if they click Ok the KeepAlive.aspx refreshes. If there is no
> >> > response
> >> > (by the 20 minute mark) the alert box goes away and is replaced by one
> >> > that
> >> > says "Your Session has timed out. Go to . . ."
> >> >
> >> > wr
> >>

>

 
Reply With Quote
 
Alvin Bruney [ASP.NET MVP]
Guest
Posts: n/a
 
      01-19-2008
These are two different clocks unrelated to each other where client clock is
(server clock - 3min) so that client always times out before server. In your
case you can, on server click ok, fire an AJAX dummy call.

> to assume it starts over on page load or on a post back -- like your
> suggestion says -- and kept a timer on the client.

Right.

> the session state (on the server) kept alive when the use clicks OK on the
> alert box button? Once a page loads and there is no post for 20 minutes,
> his
> session should time out. So rather than keeping time via mouse movements,
> I
> just want to keep time between loading of a page and between postbacks.
> The


Right, but there is no event that fires on the server that allows you to do
that. If you handle session end, it's too late. There's no
Session_AbouttoEnd event that is available, although that may be a good
feature improvement. The only thing that comes to mind is client clock set
to some value less than the server timeout clock and these two are reset
with each mouse movement.
--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
-------------------------------------------------------



"WhiskeyRomeo" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> This is all well and good (you are keeping time on the client). But how
> is
> the session state (on the server) kept alive when the use clicks OK on the
> alert box button? Once a page loads and there is no post for 20 minutes,
> his
> session should time out. So rather than keeping time via mouse movements,
> I
> just want to keep time between loading of a page and between postbacks.
> The
> alert box should pop up at least 3 minutes before session time expires.
> Since I am not going to keep track of session time on the server, I am
> going
> to assume it starts over on page load or on a post back -- like your
> suggestion says -- and kept a timer on the client.
>
> If the user clicks OK on the alert box, he should remain on the page he is
> on and an invisible post back happens to keep the session alive.
>
> WR
>
> "Alvin Bruney [ASP.NET MVP]" wrote:
>
>> I had code for this but I can't find it. Here's how I remember doing it.
>> Create a function that pops a message box. Capture the return value from
>> the
>> message box click. Let's call that function A. Map your mouse move events
>> to
>> another function, let's call that function B. Inside function B, you call
>> the javascript clearTimeout and reset the timer with a call to
>> setTimeout.
>> When the user is at the computer working the mouse move events will keep
>> rescheduling the timer. Inside Function A, you call setTimeout with a
>> suitable time and pass in function A so that function A is called after
>> the
>> time expires. If the mouse never moves, the timer will run out and the
>> function A will be called. Function A should ideally pop an alert box and
>> then redirect the user to a login page. The redirection happens after the
>> user clicks ok. If the user never comes back the message box remains.
>> Settimeout etc
>> http://www.elated.com/articles/javas...d-setinterval/
>>
>> --
>>
>> Regards,
>> Alvin Bruney [MVP ASP.NET]
>>
>> [Shameless Author plug]
>> The O.W.C. Black Book, 2nd Edition
>> Exclusively on www.lulu.com/owc $19.99
>> -------------------------------------------------------
>>
>>
>>
>> "WhiskeyRomeo" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Yes, thanks for replying -- I know it is a bad approach hence the
>> > question
>> > how can I use JavaScript to control it?
>> >
>> > WR
>> >
>> > "Alvin Bruney [ASP.NET MVP]" wrote:
>> >
>> >> No, that's not a good approach. Think security, I open several hundred
>> >> connections and now since you allow me to keep those active sessions
>> >> open,
>> >> I'll eventually cause your server to run out of memory. If the user
>> >> walks
>> >> away, the session should time out otherwise, they need to be at the
>> >> computer - this long standing design makes sense for a number of
>> >> different
>> >> reasons and you should stick to it. Having said that, I've done this
>> >> as
>> >> well
>> >> but set the app pool to recycle at midnight to 'somewhat' mitigate the
>> >> resource threat. I hope my rambling makes sense to you.
>> >>
>> >> --
>> >>
>> >> Regards,
>> >> Alvin Bruney [MVP ASP.NET]
>> >>
>> >> [Shameless Author plug]
>> >> The O.W.C. Black Book, 2nd Edition
>> >> Exclusively on www.lulu.com/owc $19.99
>> >> -------------------------------------------------------
>> >>
>> >>
>> >>
>> >> "WhiskeyRomeo" <(E-Mail Removed)> wrote in
>> >> message
>> >> news:(E-Mail Removed)...
>> >> > The below appears to be a partial answer to my problem but I don't
>> >> > to
>> >> > keep
>> >> > sessions alive simply because a user has wondered off to do
>> >> > something
>> >> > else.
>> >> > Session timeout is set to the standard 30 minutes.
>> >> >
>> >> > KEEPALIVE.aspx has:
>> >> > private void Page_Load(object sender, System.EventArgs e)
>> >> > {
>> >> > Response.AddHeader("Refresh",8000);
>> >> > }
>> >> > MyRegPage.aspx has:
>> >> > <IFRAME id=KEEPALIVE src="KEEPALIVE.aspx"
>> >> > frameBorder=no width=0 height=0 runat="server"></IFRAME>
>> >> >
>> >> > I am not a JavaScript programmer but have some very basic skills,
>> >> > how
>> >> > can
>> >> > I
>> >> > use this solution but add an alert button that pops up at the 17
>> >> > minute
>> >> > mark
>> >> > and if they click Ok the KeepAlive.aspx refreshes. If there is no
>> >> > response
>> >> > (by the 20 minute mark) the alert box goes away and is replaced by
>> >> > one
>> >> > that
>> >> > says "Your Session has timed out. Go to . . ."
>> >> >
>> >> > wr
>> >>

>>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does ASP.NET release cache items before the expiration time? Sergey via DotNetMonster.com ASP .Net 2 11-15-2006 03:48 AM
Prevent session state expiration while typing on a form jim_adams@hotmail.com ASP .Net Security 1 11-09-2005 10:35 PM
Before Sunset & Before Sunrise matt r DVD Video 2 11-25-2004 08:37 AM
warn user before session expiration JT ASP General 2 06-28-2004 06:19 PM
Re: Accessing Application State on a Cache Expiration Natty Gur ASP .Net 1 08-07-2003 01:29 PM



Advertisments