如何以编程方式检查IIS6 Web服务扩展中是否“允许”ASP.NET?

时间:2009-10-14 05:21:32

标签: iis-6

有没有办法以编程方式检查IIS 6.0上的Web Service Extensions中是否“允许”ASP.NET。我知道我可以使用aspnet_regiis.exe -i -enable设置此项,但如何使用代码检查?

此致 迪帕克

1 个答案:

答案 0 :(得分:1)

这是一个C#代码段,可以解决这个问题:

using System.DirectoryServices

static void Main(string[] args)
{
    using (DirectoryEntry de = new DirectoryEntry("IIS://localhost/W3SVC"))
    {
        foreach (string ext in de.Properties["WebSvcExtRestrictionList"])
        {
            if (ext.StartsWith("1,") && ext.IndexOf("ASP.NET v1.1") != -1)
            {
                Console.WriteLine("ASP.NET 1.1 is enabled");
            }

            if (ext.StartsWith("1,") && ext.IndexOf("ASP.NET v2.0") != -1)
            {
                Console.WriteLine("ASP.NET 2.0 is enabled");
            }
        }
    }
}

您需要在“添加引用”对话框的.NET选项卡上添加对System.DirectoryServices程序集的引用。

相关问题