tags:

views:

23

answers:

1

Application_Start and Application_End are called only once during the lifetime of the application domain – thus they aren’t called for each HttpApplication instance

Application_Start runs when first user requests a page, thus when the first instance of the HttpApplication class is created, while Application_End runs when the last instance of an HttpApplication class is destroyed.

But what if at the time of application domain being restarted there wasn’t any user requests and thus no HttpApplication instances created? Will in that case Application_End still be fired?

Thank you

+1  A: 

If I understand your question correctly, you're saying that no requests ever came, if no requests ever come in the application will never be started (i.e. no Application_Start is fired) and therefore no the Application_end wouldn't fire either.

This is not withstanding any kind of "pre-warming" code which fires up the application before requests are received in order to load up caches or things like that.

Coding Gorilla
Warmup would normally be done as a request or set or requests, hence Application_Start would be called.
Oded
"if no requests ever come in the application will never be started (i.e. no Application_Start is fired) and therefore no the Application_end wouldn't fire either." So if Application_Start isn't fired, then Application_End also isn't fired. But what if Application_Start is fired, will Application_End then also be fired even if there are no requests when runtime decides it should restart the application domain?
Yes, if the Application_Start is fired, for whatever reason, then the Application_End should also be fired.
Coding Gorilla
thank you for your help