开发者

How do I programmatically check if ASP.NET is "allowed" in IIS6 Web Service Extensions?

Is there a way to programmatically check if ASP.NET is "allowed" in Web Service Extensions on IIS 6.0. I know 开发者_如何学运维I can set this by using aspnet_regiis.exe -i -enable, but how do I check this using code?

Regards Deepak


Here's a C# snippet of code that should do the trick:

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

You need to add a reference to the System.DirectoryServices assembly on the .NET tab of the Add References dialogue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜