簡體   English   中英

在IIS中枚舉應用程序池

[英]Enumerating Application Pools in IIS

我想知道是否有一種方法可以使用ASP.net 3.5在不使用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);
                }
        }
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM