How to programmatically check if ASP.NET is allowed in IIS6 Web Services Extensions?

Is there a way to programmatically check if ASP.NET is allowed in web service extensions in IIS 6.0. I know that I can install this using aspnet_regiis.exe -i -enable, but how can I verify this using code?

Relationship Deepak

+3
source share
1 answer

Here is a C # code snippet 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 the assembly reference in System.DirectoryServicesthe .NET tab of the Add Links dialog box.

+1
source

Source: https://habr.com/ru/post/1720041/


All Articles