Enable ASP.NET in IIS6

Is there a way to enable the ASP.NET web service extension in IIS6 through C #? I am trying to simplify a website setup program for people who have not used IIS before.

+4
source share
5 answers

Looking around, all examples of this are written in vbscript. So I cheated and came up with this function:

static void EnableASPNET() { var file = "wmi.vbs"; using (var writer = new StreamWriter(file)) { writer.WriteLine("Set webServiceObject = GetObject(\"IIS://localhost/W3SVC\")"); writer.WriteLine("webServiceObject.EnableWebServiceExtension \"ASP.NET v2.0.50727\""); writer.WriteLine("webServiceObject.SetInfo"); } var process = Process.Start("cscript", file); process.WaitForExit(); File.Delete(file); } 
+2
source

C # NET. Using frameworks:

Process.Start (@ "C: \ Windows \ Microsoft.NET \ Framework \ v2.0.50727 \ aspnet_regiis", "-i -enable");

Using CMD:

C: \ Windows \ Microsoft.NET \ Framework \ v2.0.50727 \ aspnet_regiis -i -enable

This is useful.

Source: https://serverfault.com/questions/1649/why-does-iis-refuse-to-serve-asp-net-content

+4
source

You can easily access WMI (System.Management, IIRC namespace), and I believe you can install it there. However, it can be much easier to install manually, you cannot do this from the ASP.NET site, since your server will not be able to start it until it is installed ...

The principles for doing something similar can be found here.

+2
source
 // if windows 2003 if (Environment.OSVersion.Version.Major == 5 && Environment.OSVersion.Version.Minor == 2) { DirectoryEntry folderRoot = new DirectoryEntry("IIS://localhost/W3SVC"); folderRoot.Invoke("EnableWebServiceExtension", "ASP.NET v2.0.50727"); } 

Copied from: http://lastdon.blogspot.com/2006/12/setup-web-application-on-windows-2003.html

+1
source

I believe that you can also run the following command line:

 C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe -s W3SVC 

And that will recursively include the AND.NET v2.0.50727 platform for all configured websites.

0
source

All Articles