Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > using AJAX to detect Browser close

Reply
Thread Tools

using AJAX to detect Browser close

 
 
=?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?=
Guest
Posts: n/a
 
      06-15-2007
I see a lot of posts claiming that you can use AJAX or Javascript to run some
kind of "heartbeat" " server polling" that tells the server that the page is
still open. I need to know how exactly to do this (server side and client
side) or where I can find information on doing this. I want to run some code
after a page is closed and I don't want to wait for the session timeout.

if anyone has information please post explanations, code samples, or links.

thanks

 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      06-15-2007
See the window.onclose event :

http://developer.mozilla.org/en/docs/DOM:window.onclose

Also don't rely on this too much (for example the browser could crash) so
make sure it doesn't make your application do something bad if this is not
called (such as not being able to create a file because the previous one was
not deleted).

--
Patrice

"Alhambra Eidos Kiquenet" <(E-Mail Removed) >
a écrit dans le message de news:
http://www.velocityreviews.com/forums/(E-Mail Removed)...
>I see a lot of posts claiming that you can use AJAX or Javascript to run
>some
> kind of "heartbeat" " server polling" that tells the server that the page
> is
> still open. I need to know how exactly to do this (server side and client
> side) or where I can find information on doing this. I want to run some
> code
> after a page is closed and I don't want to wait for the session timeout.
>
> if anyone has information please post explanations, code samples, or
> links.
>
> thanks
>



 
Reply With Quote
 
 
 
 
Laurent Bugnion, MVP
Guest
Posts: n/a
 
      06-15-2007
Hi,

Alhambra Eidos Kiquenet wrote:
> I see a lot of posts claiming that you can use AJAX or Javascript to run some
> kind of "heartbeat" " server polling" that tells the server that the page is
> still open. I need to know how exactly to do this (server side and client
> side) or where I can find information on doing this. I want to run some code
> after a page is closed and I don't want to wait for the session timeout.
>
> if anyone has information please post explanations, code samples, or links.
>
> thanks


Th<e "heartbeat" implementation relies on the fact that every request to
active content (which includes web services) extends the session. So if
you have a web client continuously "pinging" the web server using web
services, the session never dies. However, if the web client is closed,
the "pinging" stops, and 20 minutes later (or whatever the session
timeout is set to), the session expires.

We use this in our web application and it works fine. We managed to have
sessions lasting two weeks and more without too many side effects.

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
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
How to close a TCP socket? (TCPSocket#close doesn't close it) Iñaki Baz Castillo Ruby 7 01-12-2010 01:32 PM
Browser close event (MSIE and FF): how to detect browser close ? pamelafluente@libero.it Javascript 0 01-23-2007 12:44 AM
How to detect browser close Lord2702 ASP .Net 3 10-31-2004 05:32 PM
How to detect if user has close the browser? Lord2702 ASP .Net 3 10-10-2004 06:20 AM
how to detect Browser close event. sm mehta ASP .Net 4 07-29-2003 07:26 PM



Advertisments