Calling a Page Method when the Browser Closes

后端 未结 4 1602
[愿得一人]
[愿得一人] 2021-01-16 21:48

Hi here I\'m trying to call a [webmethod] on bodyunload method.

But it is getting fired on page load itself only. How do i prevent it?

Here\'s the code I am

4条回答
  •  野的像风
    2021-01-16 21:52

    There is no way to consistently handle this type of event. There are too many causes for a session to "end". The very simplest of these would be a lost or closed connection. In this case any JavaScript fired off would never reach the server.

    Even if you can get this working the way you want it is only going to work part of the time. If you can't rely on it your time may be spent and a different solution.

提交回复
热议问题