ASP.NET Session_End event not firing

后端 未结 4 1263
南笙
南笙 2021-01-13 04:01

I\'m trying to get a database transaction to execute when an ASP.NET session ends (in simple WebForms app on Windows 2008 Server). I realize that many respondents will sugg

相关标签:
4条回答
  • 2021-01-13 04:17

    For others looking for a resolution and not finding an answer to this issue, I have seen a case where a project's Global.asax was defined with a code behind file referenced, but the events defined within the asax instead of the .cs file.

    In this case, it would fire the Session_Start, but never the Session_End, as if it was looking in the referenced .cs file.

    By removing the reference to the code behind file, Session_End started firing as expected.

    0 讨论(0)
  • 2021-01-13 04:17

    Try initializing the session from within the same method that queries the database.Do it before querying the database.

    0 讨论(0)
  • 2021-01-13 04:18

    If you don't save anything into the session, the session_end will not fire. If you're saving data in the session in the first request, and calling abandon in the same request the session_end will also not fired.

    Hope this helps!

    T

    0 讨论(0)
  • 2021-01-13 04:30

    Turns out the event WAS firing, but the code that was being executed was silently erroring out, since I wasn't properly accessing the Application object and some of my App_Code classes (which I still don't know how to do, but is worthy of a separate Stack Overflow question).

    0 讨论(0)
提交回复
热议问题