Is there any way to know that user leaving a page with asp.net?

后端 未结 5 1931
遥遥无期
遥遥无期 2020-12-10 08:54

My question is a little bit tricky. at least I think. Maybe not, anyway. I want to know if there\'s any way to know if the user is leaving the page. Whatever if he clicks \"

5条回答
  •  天涯浪人
    2020-12-10 09:43

    If the goal of this is to cleanup objects in your code-behind, is it good enough to rely on the session timeout? It would be a 20 minute delay before cleaning up those objects (or whatever you have your session timeout set for).

    But it's an easy and dependable way to do it. In your Global.asax file you'd just do this:

    Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
      ' Clean up stuff
    End Sub
    

提交回复
热议问题