Server side even on browser window close using ASP.NET & C#
Posted on 2010-08-13
I've just developed an chat application which works perfectly except for one thing. I would like to show the clients who's online and show's not, now showing online is easy. I just make IsOnline in the database true. And when the user clicks logout it's easy once again cause I do the same except false instead of true. But the problem comes in when the user closes the browser window I have no way of know if that user is offline, because I can't execute a server side event. I've tried overriding OnUnload in code behind, but the problem is when the user goes to a different page it executes that method which I don't want. So what I've figured is that asp calls the OnUnload event everytime the client leaves that page.
Any help would be appreciated,