views:

422

answers:

2

I am writing a web monitor app that gives information about all app pools / apps on my IIS server. I am looking for a way in C# to programmatically check if an IIS application is running without causing it to run if it is not.

Here is what I have found...

  1. application is running, there are one or more sessions active.
  2. all sessions dropped off...application still "running", app pool worker process is running.
  3. At some point determined by IIS, the Application_End is finally executed...however, the app pool worker process is still running.
  4. After 20 minutes, the app pool worker process finally shuts down due to inactivity.

It is between #3 and #4 that I am having trouble. The application has ended, but if I try to send an Http Request to the app, it will automatically start up. I am looking for a way to programmatically determine if the application has ended (while the worker process is still active awaiting shutdown) without restarting the Application.

I can try to provide more details if you are unsure what I am talking about.

Regards, Jeremy

A: 

Microsoft has created a VBScript file to identify the IIS Application Pools (by Process Id). If you search "iisapp.vbs" on google it should point you in the right direction.

Note: I'm not 100% sure that it will work with Windows Server 2008, but does work with 2003.

Kane
A: 

In IIS7 you can use appcmd apppool /? to see what possibilities are available.

Shiraz Bhaiji