469,578 Members | 1,869 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,578 developers. It's quick & easy.

Cancelling session when user closes browser window...

Hi:

I would like to clear session when user closes browser window by clicking
the "x" in upper right hand corner. Since this is a client side event, how
do I run server code (Session.Abandon()) when user clicks "x"?

Thanks,
Charlie
Nov 19 '05 #1
3 2376
The only way would be to trap the onbeforeunload client side event using
javascript, and then make a call to the server to kill the session. The
issue here is that this event is always raised, even if the user is just
browsing to another page on your site - so you need to make sure you only
kill the session at the right time.

"Charlie@NISH" <cf*******@nish.org> wrote in message
news:uS**************@TK2MSFTNGP12.phx.gbl...
Hi:

I would like to clear session when user closes browser window by clicking
the "x" in upper right hand corner. Since this is a client side event,
how do I run server code (Session.Abandon()) when user clicks "x"?

Thanks,
Charlie

Nov 19 '05 #2
You can never catch this completely. You can use javascript to handle the
person navigating somewhere, but there isn't any way to catch it when the
user simply exits their browser.

"Marina" wrote:
The only way would be to trap the onbeforeunload client side event using
javascript, and then make a call to the server to kill the session. The
issue here is that this event is always raised, even if the user is just
browsing to another page on your site - so you need to make sure you only
kill the session at the right time.

"Charlie@NISH" <cf*******@nish.org> wrote in message
news:uS**************@TK2MSFTNGP12.phx.gbl...
Hi:

I would like to clear session when user closes browser window by clicking
the "x" in upper right hand corner. Since this is a client side event,
how do I run server code (Session.Abandon()) when user clicks "x"?

Thanks,
Charlie


Nov 19 '05 #3
I believe this event will run even when the browser is closed.

"wbrianwhite" <wb*********@discussions.microsoft.com> wrote in message
news:B6**********************************@microsof t.com...
You can never catch this completely. You can use javascript to handle the
person navigating somewhere, but there isn't any way to catch it when the
user simply exits their browser.

"Marina" wrote:
The only way would be to trap the onbeforeunload client side event using
javascript, and then make a call to the server to kill the session. The
issue here is that this event is always raised, even if the user is just
browsing to another page on your site - so you need to make sure you only
kill the session at the right time.

"Charlie@NISH" <cf*******@nish.org> wrote in message
news:uS**************@TK2MSFTNGP12.phx.gbl...
> Hi:
>
> I would like to clear session when user closes browser window by
> clicking
> the "x" in upper right hand corner. Since this is a client side event,
> how do I run server code (Session.Abandon()) when user clicks "x"?
>
> Thanks,
> Charlie
>


Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by megha | last post: by
3 posts views Thread by JezB | last post: by
5 posts views Thread by anonmous | last post: by
5 posts views Thread by Sean | last post: by
16 posts views Thread by Jonathan Wood | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.