How to get the current list of Worker Request from IIS using C#?

江枫思渺然 提交于 2019-12-04 11:55:09

You can use the GetRequests method of the WorkerProcess type. This type is located in the Microsoft.Web.Administration assembly which can be installed using this unofficial nuget package or by adding a reference to this dll %WinDir%\System32\InetSrv\Microsoft.Web.Administration.dll

Exemple :

using (ServerManager manager = new ServerManager())
{
    while (true)
    {
        var requests = manager.ApplicationPools
                                .Where(pool => pool.Name == "FooPool")
                                .SelectMany(pool => pool.WorkerProcesses)
                                .SelectMany(wp => wp.GetRequests(10));

        Console.WriteLine(requests.Count());
        Thread.Sleep(100);
    }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!