Browser Close ....

H

Harry

My development environment is Framework 1.1, ASP.Net and IE 6.X.

I have logout button in all the screens in the application. I am doing
database activity when the user clicks on logout button. However the user
can close the application using the IE close cross mark. When the user
closes the application without logout button all my database routine and
logout activities will not be called. Any solution for this kind of
situation? Thanks for your thoughts.

Harry
 
L

Lucas Tam

Any solution for this kind of
situation?

Look at the Global.asax file. There are several event handlers you can
use... such as On Session End. On session end is executed when the session
times out - generally 20 minutes.
 
M

Marina

If you are using session state, in the session_end event, call the log out
routine for the current user.
 
S

Stephanie_Stowe

Look at the Global.asax file. There are several event handlers you can
use... such as On Session End. On session end is executed when the session
times out - generally 20 minutes.


In ASP classic, the session onend event was very unreliable. Is this not
the case in .NET? Thanks
 
K

Kevin Spencer

In ASP classic, the session onend event was very unreliable. Is this not
the case in .NET? Thanks

Define "unreliable."

Sessions in ASP would time out after an interval of inactivity (no requests
from browser). ASP.Net behaves the same way. But you could and can always be
certain of one thing: Sessions end. When they end, the Session_End Event
Handler is called. Is that reliable enough for you?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
C

Curt_C [MVP]

It's just that it may not fire till the session times out if the user used
the"X" as the OP indicated. Still the same issue(s) but it's still about
your only real way of doing it.
 
H

Harry

when the user closes the IE by clicking the X mark on the title bar,
Session_End routine is not getting triggered.
Am I doing something wrong?
Harry
 
M

Marina

No. That will get triggered when the session times out due to inactivity.
That setting is in web.config.
 
M

Marina

The conclusion is that you can handle it, but only when the session times
out. There is no way the server can know what the user does on their
computer as far as which IE windows are kept open, and which are closed
suddenly. All the server can know is the last time a request was made from a
client with a particular session id. And when the client hasn't made a
request for some amt of time, it can kill the session and raise the
session_end event.
 
C

Curt_C [MVP]

Exactly as mentioned... it's your only real choice other then rethinking
what you are trying to do.
It's a misconception in the methodology. WWW isn't designed to act like a
windows app, dont try to force it.
 
S

Stephanie_Stowe

In ASP classic, the session onend event was very unreliable. Is this
not
Define "unreliable."

Sessions in ASP would time out after an interval of inactivity (no requests
from browser). ASP.Net behaves the same way. But you could and can always > be
certain of one thing: Sessions end. When they end, the Session_End Event
Handler is called. Is that reliable enough for you?


In classic ASP, Sessions certainly ended. But the Session_OnEnd event did
NOT always fire. That is what I meant by unreliable.
 
K

Kevin Spencer

I started using ASP when it first came out. In all these years I have never
heard anyone claim that the Session_End event would not fire every time. I
would love to see your evidence.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
L

Lucas Tam

when the user closes the IE by clicking the X mark on the title bar,
Session_End routine is not getting triggered.
Am I doing something wrong?

Session_End gets triggered when the Session Times Out - not when the user
closes IE.

I believe the default Session Time out is 20 minutes.
 
S

Stephanie_Stowe

I am not the only one to contend this. Check out

http://www.aspfaq.com/show.asp?id=2078

This is a fairly common conversation over at ...inetserver.asp.general. I
do not know if it still applies.

Long ago, I ran a test to track the firing of Session_OnEnd. I no longer
have access to this test since it was 2 jobs ago. But it was clear that
when the session expired, the event did not always fire. I wish I had
better evidence than that for you, but unfortunately I do not.

Now, as for the faq article, I never even considered using recordsets and
whatnot at session scope for a host of reasons, and this consideration
never even entered my mind.

Stephanie
 
L

Lucas Tam

(e-mail address removed) wrote in
http://www.aspfaq.com/show.asp?id=2078

This is a fairly common conversation over at
...inetserver.asp.general. I do not know if it still applies.

Long ago, I ran a test to track the firing of Session_OnEnd. I no
longer have access to this test since it was 2 jobs ago. But it was
clear that when the session expired, the event did not always fire. I
wish I had better evidence than that for you, but unfortunately I do
not.

Were you testing on IIS 5.0? Like the FAQ says, the reliablity problems
with IIS have been fixed since v5.0. I know Session End was a problem with
older versions of IIS, but I haven't heard of any compaints on v5.0 or
v6.0.
 
K

Kevin Spencer

In ASP classic. it was not possible to do database ops in the Session_OnEnd
event handler. However, in ASP.Net, it certainly is.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
B

bruce barker

note: the Session On End event only fires for inproc session managers.

-- bruce (sqlwork.com)
 
G

Guest

use javascript xmlHttp object and execute that file on the server what ever
operation u want to do.Call that javascript method on bodt unload
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top