in the morning, I got up and saw an Article In aspalliance in Google subscription. I read it with interest immediately. The title of the question is:
handle browser Close event on the server-side
indicates capturing browser close events on the server. This technology is a well-known problem. I want to see how it solves it. The result shows that the onUnload Event of the original body triggers the pagemethod of Asp.net ajax to release resources on the server. Is that strange? When the PostBack is refreshed, all events trigger the onUnload Event. Do you have to release all resources once? Result In the first comment:
This article seemed promising, but unfortunately the Javascript chain of events is going to cause undesired results.
second comment:
unfortunately, the code in this article will not work. the onUnload Event fires every time you leave a page, so you'll be abandoning the session all the time.
the following comments are also about this does not work issue, but some people have given several reasons for this failure:
1) the user has javascript disabled
2) the user's browser doesn't support JavaScript
3) The user kills the browser Process
4) the user turns off their machine or has a power cut
Some people have made strange moves:
One proposed solution is to use the mouse pointer to locate the window close button "X ". off course this will be purely based on the mouse movement but then you shoshould also consider the chances of user resizing the window and then closing it. so, basically what is required is to get the mouse coordinates based on the openned browser window.
In short, it will not work, because: The problem with onUnload is that it will be fired even if you refresh the page or fire an ASP. NET PostBack event from any server side button.
However, some people have proposed the following solutions:
Another option for this case is that you use a keep alive functionality in your web application. after implementing keep alive, u can keep your session expire time to a short interval, say 1 or 2 mins. through this u can check for the session after every 1 or 2 mins and abandon it accordingly
However, it's really a sweat: Foreign MVPs write such articles that haven't been tested by themselves and then publish them to what I think is a Bible-like website? Compared with the heroes such as Lu Zhenyu and Lao Zhao in the courtyard, it is really hard to sweat... compared with the developers outside of China, the younger brothers in the garden are happy.