Avatar of countrymeister
countrymeister asked on

How to detect the browser close when the browser is closed from Task Manager

I have a system where I need to see active users, so I created a web page to see the logged in users
In the main ASP.NET application I record the login time when they sign on and logout time when they sign off or the session ends

When the close the browser I need to log them off, (update their logout timestamp)
Hence I need to trap the browser close click , which I do

I have posted previously and found a solution to track the browser click
https://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_26612638.html
https://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_26614273.html
http://www.codingforums.com/showthread.php?t=37279

I need to find a way how to update the database when the user goes to Task Manager and kills the browser session any code sample will be great

Please note my app has a login page, master page and few other aspx pages that use the master page.
ASP.NETJavaScriptAJAX

Avatar of undefined
Last Comment
countrymeister

8/22/2022 - Mon
robasta

But when you click "End Process" in Task Manager it forces the process to terminate. It will lose whatever data hasn't been saved.

This is made worse by the client/server architecture of the web. on the client machine, you can only run client side code (js etc).

If it had been a windows forms app, I would suggest this topic: http://stackoverflow.com/questions/2055753/how-to-gracefully-terminate-a-process.
ASKER
countrymeister

So can you initiate anything in js within a webpage to see if the process hosting is being killed.
robasta

i dont want to rule it out completely but i dont think you can.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Mahmood Dehghan

The only way I think is to use an AJAX request from client every 1 minute or so.
if server didn't receive the request in 5 minutes, then the client is disconnected.
ASKER CERTIFIED SOLUTION
countrymeister

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
countrymeister

Need points refunded, get some hal bked answers here