In ASP.NET, I'm looking for a way to audit a user leaving my application. To be specific, I'd like to insert a 'logout' record in an audit table in SQL Server when the user's session is abandoned/destroyed for any reason (not necessarily because of a call to session.abandon)
I have a 'SessionHelper' class that manages the session setters/getters.
I've tried posting back in Session_End in Global.asax, but it never fired this event even after the timeout expired.
I've tried overriding 'finalize' in the SessionHelper class and doing it there when the class is destroyed, but it did not fire that event either.
I'd try implementing IDisposable in the SessionHelper, but I don't know where to call it so that it always gets called.
What is the proper way to audit a user leaving your ASP.NET application?
Thank you!