When exactly does Application_End get called and how can I manually cause this?
Asked Answered
M

2

7

I know that the event handler for this event is called when the application pool is recycled by IIS, but when does that happen? What about if using the built-in Visual Studio server (Cassini)? If I kill the server process, would Application_End be fired?

UPDATE: I know about web.config and BIN folder changes. I'm interested in the case of shutting down the pool after the application has been idle for a period of time without touching anything.

Marni answered 5/6, 2009 at 12:26 Comment(1)
BTW, shutting down Cassini from the Tray Icon in fact raises the ApplicationEnd event.Marni
F
7

Like Nick said, "An application pool will recycle when... some of the recycle limits are hit on the application pool configuration." In IIS you can set the recycling conditions in the application pool settings. You can use fixed intervals (every X minutes or requests), a specific time of day, or memory-based maximums in MB (max virtual memory or max private memory), or a combination of any of these. You can also set an idle time-out in minutes after which a worker process is terminated.

IIS Recycling Settings

IIS Advanced Settings

Footlight answered 5/6, 2009 at 13:11 Comment(0)
R
5

An application pool will recycle when you change the web.config or the /bin directory, or some of the recycle limits are hit on the application pool configuration. The same is true for Cassini except it doesn't have an application pool, so it will trigger any time the web.config or /bin directory is changed. I am not sure about killing the instance of Cassini.

Rothberg answered 5/6, 2009 at 12:31 Comment(2)
Thanks. I didn't express this clearly, but I was more interested in the case when the application is idle and you don't change anything. I.e. what does idle mean - is it a configurable option in IIS how long to wait before shutting down the app pool?Marni
Thanks for the hint on changes to the /bin directory. You saved my nights sleep. Literally :).Incorporeal

© 2022 - 2024 — McMap. All rights reserved.