By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,967 Members | 1,625 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,967 IT Pros & Developers. It's quick & easy.

Detect Close Browser

P: n/a
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

Jun 15 '07 #1
Share this Question
Share on Google+
11 Replies


P: n/a
You can't detect when the browser is closed.

"Alhambra Eidos Kiquenet" <Al*******************@discussions.microsoft.com >
wrote in message news:DA**********************************@microsof t.com...
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

Jun 15 '07 #2

P: n/a
"Alhambra Eidos Kiquenet" <Al*******************@discussions.microsoft.com >
wrote in message news:DA**********************************@microsof t.com...
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

Jun 15 '07 #3

P: n/a
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" <Al*******************@discussions.microsoft.com >
wrote in message news:DA**********************************@microsof t.com...
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

Jun 15 '07 #4

P: n/a
"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:ek**************@TK2MSFTNGP03.phx.gbl...
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

Jun 15 '07 #5

P: n/a
And using onbeforeunload ??

<script language=JavaScript>
<!--
function window::onbeforeunload()
{
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
Jun 15 '07 #6

P: n/a
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" <ma**@markNOSPAMrae.netwrote in message
news:uO**************@TK2MSFTNGP02.phx.gbl...
"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:ek**************@TK2MSFTNGP03.phx.gbl...
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

Jun 15 '07 #7

P: n/a
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.
Jun 15 '07 #8

P: n/a
And using onbeforeunload ??

That also fires if they navigate away, not just close the browser.
Jun 15 '07 #9

P: n/a
"Aidy" <ai**@noemail.xxxa.comwrote in message
news:gs*********************@bt.com...
>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

Jun 15 '07 #10

P: n/a
"Alhambra Eidos Kiquenet" <Al*******************@discussions.microsoft.com >
wrote in message news:AD**********************************@microsof t.com...
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

Jun 15 '07 #11

P: n/a
"Aidy" <ai**@noemail.xxxa.comwrote in message
news:_N******************************@bt.com...
>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

Jun 15 '07 #12

This discussion thread is closed

Replies have been disabled for this discussion.