有没有一种方法可以以编程方式检查IIS 6.0上的Web服务扩展中是否“允许” ASP.NET。我知道可以使用aspnet_regiis.exe -i -enable
进行设置,但是如何使用代码进行检查?
问候
迪帕克
最佳答案
这是应该可以解决问题的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
程序集的引用。
关于iis-6 - 如何以编程方式检查IIS6 Web服务扩展中是否“允许” ASP.NET?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1564374/