using AJAX to detect Browser close

Discussion in 'ASP .Net' started by =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?=, Jun 15, 2007.

  1. 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
     
    =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?=, Jun 15, 2007
    #1
    1. Advertising

  2. =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?=

    Patrice Guest

    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" <>
    a écrit dans le message de news:
    ...
    >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
    >
     
    Patrice, Jun 15, 2007
    #2
    1. Advertising

  3. 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
     
    Laurent Bugnion, MVP, Jun 15, 2007
    #3
    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. sm mehta

    how to detect Browser close event.

    sm mehta, Jul 29, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    5,196
    Steve C. Orr, MCSD
    Jul 29, 2003
  2. Lord2702
    Replies:
    3
    Views:
    663
  3. Lord2702

    How to detect browser close

    Lord2702, Oct 30, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    15,640
    Ken Dopierala Jr.
    Oct 31, 2004
  4. Iñaki Baz Castillo
    Replies:
    7
    Views:
    919
    Iñaki Baz Castillo
    Jan 12, 2010
  5. Replies:
    0
    Views:
    528
Loading...

Share This Page