Click here to Skip to main content
14,357,666 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am planning to develop a windows service for getting the IIS Application Pool Name and Its Status i.e. Running Or Stopped. How can I achieve this?
Please provide sample example if any.
Appreciate any Help.


What I have tried:

public static string GetApplicationPoolNames()
ServerManager manager = new ServerManager();
string status;
//string DefaultSiteName = System.Web.Hosting.HostingEnvironment.ApplicationHost.GetSiteName();
//Site defaultSite = manager.Sites[DefaultSiteName];
string appVirtaulPath = HttpRuntime.AppDomainAppVirtualPath;
string mname = System.Environment.MachineName;
string appPoolName = string.Empty;
manager = ServerManager.OpenRemote(mname);
ObjectState result = ObjectState.Unknown;

ApplicationPoolCollection applicationPoolCollection = manager.ApplicationPools;

foreach (ApplicationPool applicationPool in applicationPoolCollection)
//result = manager.ApplicationPools[applicationPool].State;
string resudlt = applicationPool.Name;
Console.WriteLine("State : " + resudlt);


return appPoolName;
Updated 3-Jun-16 5:17am

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Refer below.



This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100