Session_End never firing

J

JezB

Why is my Session_End event in global.asax never firing ? I've tried
fiddling with the timeouts but still nothing.
Ideally I want to do some processing whenever someone leaves my web
application (navigates somewhere else or closes the browser).
 
M

Marina

Session_End does not fire when someone navigates elsewhere or closes the
browser. It fires when the idle timeout is reached, so you cannot do
redirects or anything with the response, if this is how you are testing
session_end firing. Try putting in a breakpoint.
 
J

JezB

Ah I see. So it's not really the opposite of Session_Start ...
Is there any reliable way to capture when a user leaves my site ? I'm trying
to audit session activity.
 
M

Marina

There is really no reliable way to do anything when the user shuts their
browser window for example.

You could in theory try to capture the event in the onunload event on the
client and make some sort of call to the server to say the the user is
leaving the site. One of the issues with this, is that onunload fires
whenever the pages is unloaded - so for navigating elsewhere to your site,
or just doing a postback. So you would need to keep track of whether or not
the user just did something but stayed within your site, or is actually
leaving, which is tricky.

But overall, there is no easy way to do this, so you would just wait till
the idle timeout is reached (or the user manually logs out) to do your
cleanup.
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top