5
我想知道是否有方法來枚舉使用ASP.net 3.5本地IIS服務器上的應用程序池集合(而不是在給定池中的應用程序 - 但池本身),而不使用的WMI,如果有的話,有人可以提供一個鏈接或例子來說明這是如何完成的?在IIS中枚舉應用程序池
(我忘了添加IIS版本是6.0)。
我想知道是否有方法來枚舉使用ASP.net 3.5本地IIS服務器上的應用程序池集合(而不是在給定池中的應用程序 - 但池本身),而不使用的WMI,如果有的話,有人可以提供一個鏈接或例子來說明這是如何完成的?在IIS中枚舉應用程序池
(我忘了添加IIS版本是6.0)。
這應有助於:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.DirectoryServices;
namespace AppPoolEnum
{
class Program
{
static void Main(string[] args)
{
DirectoryEntries appPools =
new DirectoryEntry("IIS://localhost/W3SVC/AppPools").Children;
foreach (DirectoryEntry appPool in appPools)
{
Console.WriteLine(appPool.Name);
}
}
}
}
我還要補充,這將不會在部分信任的工作。
另一種可能有用的方法。
using System.IO;
using Microsoft.Web.Administration;
namespace AppPoolEnum
{
class Program
{
static void Main(string[] args)
{
foreach (var appPool in new ServerManager().ApplicationPools)
{
Console.WriteLine(appPool.Name);
}
}
}
}
這可以在nuget軟件包'Microsoft.Web.Administration' – pilotcam 2017-02-09 16:09:32