Calling a Page Method when the Browser Closes

后端 未结 4 1608
[愿得一人]
[愿得一人] 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 22:18

    What you are attempting to do is a bad idea. Consider putting less data in the session, or lowering the timeout.

    Perhaps you don't realise that onunload fires when the user refreshes or navigates away from the page. So assuming your code actually worked, if you user refreshed their page then their session would be terminated. If they visited any other page on the site their session would also be terminated!

    Probably not the functionality you were hoping for!

提交回复
热议问题