Click here to Skip to main content
15,902,938 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

When Page is closed from X button how to update the database in asp.net.

Suppose user closed the page from X button by mistake or purposely how to update the login status in database.

I know we can use this in Global file in sesssion end and application end. but the event is not fire.

Any suggestion on this.

Thanks
Basit.
Posted

 
Share this answer
 
You have to understand that because of the disconnected nature of the web, when user closes the browser window from the X button, the server knows nothing of it...No event send to the server, whatsoever...
The server-side events of session-end and application-end will be launched when time will come, but the data from the client lost already at that point...
As you are talking about the login status, you should store that status upon change, so when user finishes the login store the status, and then let user play with the page...
If you mean to set login status to 'off' when user closing the browser, you should use the article below, but be sure to do the same on session-end too as all the solutions in that article have no 100% success...
How to end user session when browser closed[^]
Execute server side code on close of a browser[^]
 
Share this answer
 
v2
Comments
basitsar 13-Jan-15 3:37am    
Thanks Kornfeld. But this solution is not work in google chrome. IE and Firefox is Ok.

thanks
Basit.
Kornfeld Eliyahu Peter 13-Jan-15 3:41am    
Added a second article to check...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900