有没有办法以编程方式检查IIS 6.0上的Web Service Extensions中是否“允许”ASP.NET。我知道我可以使用aspnet_regiis.exe -i -enable
设置此项,但如何使用代码检查?
此致 迪帕克
答案 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
程序集的引用。