Detect Close Browser

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

  1. =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?=, Jun 15, 2007
    #1
    1. Advertising

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

    Aidy Guest

    You can't detect when the browser is closed.

    "Alhambra Eidos Kiquenet" <>
    wrote in message news:D...
    > Hi misters, I have an aplication web asp.net 2.0 and I am Trying to detect
    > the close event in browser, which is the best performance for do this ?
    >
    > What's up with Alt+F4, Refresh, user clicks X, etc ?
    >
    > Thanks.
    > --
    > http://www.alhambra-eidos.es/web2005/index.html
    > www.kiquenet.net
    >
     
    Aidy, Jun 15, 2007
    #2
    1. Advertising

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

    Mark Rae Guest

    "Alhambra Eidos Kiquenet" <>
    wrote in message news:D...

    > Hi misters,


    LOL!

    > I have an aplication web asp.net 2.0 and I am Trying to detect
    > the close event in browser


    You can't...

    > What's up with Alt+F4, user clicks X, etc ?


    Nothing is up with with them - they perform the same function in a web
    browser application as in any other Windows desktop application...


    --
    http://www.markrae.net
     
    Mark Rae, Jun 15, 2007
    #3
  4. =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?=

    Mark Rae Guest

    "Eliyahu Goldin" <> wrote in
    message news:...

    > See if Response.IsClientConnected property can help you.


    I'm really curious to know how you think this could possibly detect that the
    user has closed the browser after the HttpResponse has been streamed down to
    the client...
    http://www.devx.com/vb2themax/Tip/18495
    http://www.thescripts.com/forum/thread492832.html

    1) Client sends request to webserver
    2) Webserver processes request
    3) Webserver sends response to client
    4) Client closes browser / navigates to another site

    There simply is no way for the webserver to know that 4) has happened...


    --
    http://www.markrae.net
     
    Mark Rae, Jun 15, 2007
    #4
  5. And using onbeforeunload ??

    <script language=JavaScript>
    <!--
    function window::eek:nbeforeunload()
    {
    if ( window.event.clientY < 0 )
    {
    // User closed the browser via the 'X' button;

    window.event.returnValue =
    'You are closing the application without saving the current transaction.';
    }
    }
    // -->
    </script>

    any solution using cookies ??


    Thanks in advance
     
    =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?=, Jun 15, 2007
    #5
  6. =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?=

    Aidy Guest

    > I don't. But there are scenarios where this property can be useful.

    It is only useful if you are streaming a lot of data and want to check that
    the client is still connected and receiving the data. If not you can
    terminate your code and save some resources. Once the page has downloaded
    the client is always disconnected as HTTP is a connectionless protocol.
     
    Aidy, Jun 15, 2007
    #6
  7. =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?=

    Aidy Guest

    > And using onbeforeunload ??

    That also fires if they navigate away, not just close the browser.
     
    Aidy, Jun 15, 2007
    #7
  8. See if Response.IsClientConnected property can help you.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin


    "Alhambra Eidos Kiquenet" <>
    wrote in message news:D...
    > Hi misters, I have an aplication web asp.net 2.0 and I am Trying to detect
    > the close event in browser, which is the best performance for do this ?
    >
    > What's up with Alt+F4, Refresh, user clicks X, etc ?
    >
    > Thanks.
    > --
    > http://www.alhambra-eidos.es/web2005/index.html
    > www.kiquenet.net
    >
     
    Eliyahu Goldin, Jun 15, 2007
    #8
  9. =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?=

    Mark Rae Guest

    "Aidy" <> wrote in message
    news:...

    >> And using onbeforeunload ??

    >
    > That also fires if they navigate away, not just close the browser.


    Not only that, it will fire while the user moves from page to page within
    the same site...


    --
    http://www.markrae.net
     
    Mark Rae, Jun 15, 2007
    #9
  10. =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?=

    Mark Rae Guest

    "Alhambra Eidos Kiquenet" <>
    wrote in message news:...

    > And using onbeforeunload ??


    > <script language=JavaScript>


    Stop - think - take a step back...

    What you have written is a client-side JavaScript function - how can the
    server ever possibly know about it...???

    > any solution using cookies ??


    Same answer - the server can only detect the presence of cookies when it
    receives an HttpRequest from a client browser...


    --
    http://www.markrae.net
     
    Mark Rae, Jun 15, 2007
    #10
  11. =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?=

    Mark Rae Guest

    "Aidy" <> wrote in message
    news:...

    >> I don't. But there are scenarios where this property can be useful.

    >
    > It is only useful if you are streaming a lot of data and want to check
    > that the client is still connected and receiving the data. If not you can
    > terminate your code and save some resources. Once the page has downloaded
    > the client is always disconnected as HTTP is a connectionless protocol.


    Yes indeed...


    --
    http://www.markrae.net
     
    Mark Rae, Jun 15, 2007
    #11
  12. > I'm really curious to know how you think this could possibly detect that
    the
    > user has closed the browser after the HttpResponse has been streamed down

    to
    > the client...

    I don't. But there are scenarios where this property can be useful. All I am
    saying is that the OP can check whether these scenarios are relevant for
    him.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin


    "Mark Rae" <> wrote in message
    news:...
    > "Eliyahu Goldin" <> wrote in
    > message news:...
    >
    > > See if Response.IsClientConnected property can help you.

    >
    > I'm really curious to know how you think this could possibly detect that

    the
    > user has closed the browser after the HttpResponse has been streamed down

    to
    > the client...
    > http://www.devx.com/vb2themax/Tip/18495
    > http://www.thescripts.com/forum/thread492832.html
    >
    > 1) Client sends request to webserver
    > 2) Webserver processes request
    > 3) Webserver sends response to client
    > 4) Client closes browser / navigates to another site
    >
    > There simply is no way for the webserver to know that 4) has happened...
    >
    >
    > --
    > http://www.markrae.net
    >
     
    Eliyahu Goldin, Jun 15, 2007
    #12
    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,205
    Steve C. Orr, MCSD
    Jul 29, 2003
  2. Lord2702
    Replies:
    3
    Views:
    673
  3. Lord2702

    How to detect browser close

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

Share This Page