Global.asax Application_End questions

J

Jim Owen

My .Net book states that the Application_End event handler in Global.asax
gets called typically about 20 minutes after the last HTTP request. My
question is: what is the best way to debug my Application_End code? I could
of course add a button or something to a form to run the code explicitly,
but I want to be sure it is really getting called after 20 minutes. I assume
that if I put a breakpoint in my Application_End code, and then run the
application from within VS.Net, that 20 minutes later my breakpoint isn't
going to get hit and suddenly I can step through it. Lastly, what the code
does is update the database with the current application cache, and I want
this to happen right afdter I exit the application, not 20 minutes later,
while I'm developing the app, I'm going in and out all the time and 20
minutes won't pass without an HTTP request pretty much all day.

How is this stuff typically handled?
 
D

David Waz..

that's the nature of the beast... you don't know when the
application will end.

You said "when I exit the application" - that event
doesn't happen. you close the browser, but you
don't "Exit" a web application... not unless you have a
button that says "Exit Application" - and of course,
that's silly.

You can either sit in the debugger, waiting for the app to
die, add a button to simulate the event, or just add a
button that calls your end-of-application routines to test
it, then implement the code and all should be A-ok
 
K

Kevin Spencer

You want the Session_End event, not the Application_End event. The
Session_End Event occurs whenever a single user Session ends. As you pointed
out, in a web site with many users accessing it every day, the
Application_End Event may never fire. In either case you're going to have to
wait. There's no way to force it from the browser side. If the user
navigates away, or closes their browser, the server has no way of knowing
this (HTTP is stateless). When the Session times out, the event will fire.

HTH,

Kevin Spencer
Microsoft FrontPage MVP
Internet Developer
http://www.takempis.com
Some things just happen.
Everything else occurs.
 
J

Jim Owen

Well now I'm quite confused. I have been able to debug my Application_End
code and it works fine. Then just for grins I put a breakpoint in there and
let the browser sit there while I ate lunch, and it never hit my
Application_End code. What am I doing wrong? All I've done is put a call to
a method in the Global.asax file under Application_End.
 

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

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top