Session_End Event

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Does the Session_End event actually fire? I am building an ASP.NET
application, and so far I have an HTML page and a single asp page. The HTML
is the home page. I have code in the Global.asax file's Session_End handler
that closes the session's connections to the SQL backend. The thing never
fires! After my app closes, I run sp_who in Query Analyzer to see connections
to the database. Low and behold my ASP connections are still there!
What could I be doing wrong?

Thanks in advance
 
You shouldn't be storing connection/commands/readers in Session. The
best model is to open the connection late and release the connection
early.

Er, and when I say this I mean open the connection when you need it... do
all your dataaccess... then close it ASAP in the same method. I wasn't sure
if that implication got across... :)

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
Oh yes I understood quite well what you mean.

On the other I take it though to mean that the Session_End event cann't
really be relied upon!

Thanks
 
On the other I take it though to mean that the Session_End event
cann't really be relied upon!

It certainly is not called if you're using the NT State Service or SqlServer.
It should be called if stored InProc (but not sure why it's not in your scenario).

In general I recommend to not use session state. For small, quick and dirty
apps, then perhaps. But for large apps, I think it's a mistake. There are
other ways of doing things.

-Brock
DevelopMentor
http://staff.develop.com/ballen
 
session timeout, usually after 20 minutes. if you wait long enough and are
using inproc sessions, it should fire.

-- bruce (sqlwork.com)
 
I am writing an application in ASP.Net Version 1.1. I am using InProc mode.
I am trying to capture the time that Session Timeout occurs. However, I have
never been able to get the Session_End event to fire. I that maybe the
database code was too complex to complete before session timeout finished so
I simplified the code to a simple write to a text file. This still does not
run. I inserted a break point into the event code, changed the session
timeout time to five minutes and sat waited for the code to run and stop at
the break point. Nothihng. All the discussions and documentation I've read
has stated that the session end event is supposed to fire at Session timeout
when state mode is set to inproc. I do not know why this is happening.


ERJ MCSD MCDBA
 
Back
Top