Session_End Event

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
 
B

Brock Allen

What could I be doing wrong?

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

Guest

I will try that. Thanks!

Brock Allen said:
You shouldn't be storing connection/commands/readers in Session. The best
model is to open the connection late and release the connection early.
 
B

Brock Allen

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... :)
 
G

Guest

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
 
B

Brock Allen

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.
 
B

Bruce Barker

session timeout, usually after 20 minutes. if you wait long enough and are
using inproc sessions, it should fire.

-- bruce (sqlwork.com)
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top