how to get all IIS worker Processes list into my C

2019-07-30 14:44发布

问题:

i have a server in which i published a asp.net web site. i want to create a console application which show how many worker processes are in the IIS. please any help

回答1:

You can add this reference in project Microsoft.Web.Administration assembly which can be installed using this nuget package or by adding a reference to this dll %WinDir%\System32\InetSrv\Microsoft.Web.Administration.dll

using (ServerManager manager = new ServerManager())
{
        var requests = manager.ApplicationPools
                                .SelectMany(pool => pool.WorkerProcesses).Count();
        Console.WriteLine(requests);
}