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 suggest not to rely on the Session_End event (as I've read in a hundred forum posts on this topic yielded by a Google search). Please humor me.
I've done these things:
Enabled session state in web.config: <sessionState mode="InProc" cookieless="false" timeout="1" />
Confirmed that the Session_End event does NOT fire when I call Session.Abandon() OR when the session times out.
Confirmed that the session IS timing out after 1 minute (as configured above).
Confirmed that I'm not attempting to access any Request or Response or Server objects (which I understand would silently error out).
EDIT: I've also confirmed that I'm storing data in the session--I use a number of session variables to store different data points, and these are instantiated when the user logs in to the app.
EDIT: I've also confirmed that I'm not creating the session and then abandoning it in the same request. As noted above, the problem exists even when the session times out (i.e., no Request is made).
Please help!
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With