Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.00/5 (1 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.

Thanks..!

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;
}
Posted
Updated 3-Jun-16 4:17am

1 solution

Refer below.


[^]


[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900