枚举 IIS 中的应用程序池

发布于 2024-08-04 11:10:09 字数 149 浏览 3 评论 0原文

我想知道是否有一种方法可以在不使用 WMI 的情况下使用 ASP.net 3.5 枚举本地 IIS 服务器上的应用程序池集合(不是给定池中的应用程序 - 而是池本身),如果可以的话有人可以吗提供一个链接或示例来说明如何完成此操作?

(我忘了添加IIS版本是6.0)。

I am wondering if there is a way to enumerate the collection of applications pools (not the applications in a given pool - but the pools themselves) on the local IIS server using ASP.net 3.5 without the use of WMI, and if so can someone provide a link or example to how this is done?

(I forgot to add the IIS version is 6.0).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我的奇迹 2024-08-11 11:10:09

另一种方法可能会有所帮助。

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);
                }
        }
    }
}

Another way that might be helpful.

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);
                }
        }
    }
}
心碎的声音 2024-08-11 11:10:09

这应该有帮助:

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);
            }
        }
    }
}

我还应该补充一点,这在部分信任中不起作用。

This should help:

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);
            }
        }
    }
}

I should also add this won't work in partial trust.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文