Need help keeping track of users "online" (i.e. viewing the web si

G

Guest

I've got a user table with a field called Online, and when a user logs in, I
set a value in this column to indicate they are online. And in the same
fashion, when they click the logout button, I update this same field to
indicate they are offline.

However, how do I handle this when a user just X's out of the browser
without logging off? I've set break points in the global.asax.cs file but
the Session_End and Application_End functions never get executed if the
browser is closed.

Can anyone recommend a better solution for me, or tell me how to execute
updating my code to set a user offline if someone exits closing the browser
or navigating away from my page?

Thanks for the help.
 
J

John Timney \(ASP.NET MVP\)

Session end doesn't happen when the browser closes, it happens when the
server times out the session due to session inactivity. Are you perhaps
expecting the session end to fire on browser close?

--
Regards

John Timney
ASP.NET MVP
Microsoft Regional Director
 
G

Guest

Actually I'm looking for anything that fires when the browser is closed or my
page is navigated away from.

Can you point me in the direction of what I'm looking for?

Thanks for your response
 
G

Guest

Hi
not sure if this was answered in the link Patrick gave as I couldn't follow
the link

here's something to try
Set Session.Timeout = 2 in the Session Start Event
In your Session End event add in a few dummy lines of code and set a break
point
Now start in debugging mode and either leave your browser on the page that
comes up or navigate to a different site altogether
switch back to VisualStudio.NET
wait 2 minutes then hey presto the break point should be hit
If you want to use any session variables in the End event just initalise
them in the the start event, if you dont they seem to go missing

It also works for when users X out of the browser

Cheers

Felix
 

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,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top