469,267 Members | 1,082 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

How can I make sure that Session_End is called when the user closes the browser?

Hi guys,

I just want to do some clean up in the Session_End at Global.aspx.

However, if the user closes the browser window that event is not fired.

how can I call explicity protected void Session_End(Object sender, EventArgs
e)
when the user closes the browser window?

possible at all?

TA
Nov 19 '05 #1
6 1938
Annie wrote:
Hi guys,

I just want to do some clean up in the Session_End at Global.aspx.

However, if the user closes the browser window that event is not
fired.
how can I call explicity protected void Session_End(Object sender,
EventArgs e)
when the user closes the browser window?


Not possible. You're working with a connectionless architecture. The
server has no knowledge of when the user closes their browser.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003


Nov 19 '05 #2
Annie wrote:
Hi guys,

I just want to do some clean up in the Session_End at Global.aspx.

However, if the user closes the browser window that event is not
fired.
how can I call explicity protected void Session_End(Object sender,
EventArgs e)
when the user closes the browser window?

possible at all?

TA


The session does not end when the user closes the browser, but (default)
20 minutes after the last request to the site. (So if he was busy for 30 minutes
reading a single page, the session would have ended).

There is no (reliable) way to detect that the user has closed the browser,
navigated away from the site, or lost his internet connection.

Hans Kesting
Nov 19 '05 #3
KMA
which is why ebanking software has a "log out" button, so it can call
session abort.

"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:eN**************@TK2MSFTNGP14.phx.gbl...
Annie wrote:
Hi guys,

I just want to do some clean up in the Session_End at Global.aspx.

However, if the user closes the browser window that event is not
fired.
how can I call explicity protected void Session_End(Object sender,
EventArgs e)
when the user closes the browser window?

possible at all?

TA
The session does not end when the user closes the browser, but (default)
20 minutes after the last request to the site. (So if he was busy for 30

minutes reading a single page, the session would have ended).

There is no (reliable) way to detect that the user has closed the browser,
navigated away from the site, or lost his internet connection.

Hans Kesting

Nov 19 '05 #4
wow gettting very interesting!
How about catching it in client side using Javascript and something and
passing it to server somehow?
not possible at all?
"Annie" <my**************@gmail.com> wrote in message
news:43********@dnews.tpgi.com.au...
Hi guys,

I just want to do some clean up in the Session_End at Global.aspx.

However, if the user closes the browser window that event is not fired.

how can I call explicity protected void Session_End(Object sender,
EventArgs e)
when the user closes the browser window?

possible at all?

TA

Nov 19 '05 #5
Annie wrote:
wow gettting very interesting!
How about catching it in client side using Javascript and something
and passing it to server somehow?
not possible at all?


Sessions use a sliding expiration. That means that as soon as you "pass it
on to the server", you reset your Session expiration, thereby delaying the
execution of Session_End, not expediting it.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003


Nov 19 '05 #6
Annie wrote:
wow gettting very interesting!
How about catching it in client side using Javascript and something
and passing it to server somehow?
not possible at all?


Hit Send too soon. :)

Of course you could have your browser call a page that calls
Session.Abandon, but you have to remember that there is no way to hook a
client side event ONLY when the browser is closed. It would be impossible
(as far as I can think right off this early in the AM) to detect the browser
closing correctly.

One more thing to add. Session_End is indeterminate. Even if you call
Session.Abandon, you cannot guarantee when Session_End will get called.

--
Jim Cheshire
JIMCO Software
http://www.jimcosoftware.com

FrontPage add-ins for FrontPage 2000 - 2003


Nov 19 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Chris Sibel | last post: by
5 posts views Thread by JezB | last post: by
3 posts views Thread by MattB | last post: by
1 post views Thread by Timo | last post: by
reply views Thread by rsford31 | last post: by
7 posts views Thread by Bruno | last post: by
8 posts views Thread by Roger | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.