I am trying to add a website on IIS 5.1
When I try to create an application pool for my new site with my function below, I have this strange error "system.directoryNotFound Exception ... in CreateAppPool"
The strangest thing is that the creation of the application pool function perfectly on a pc windows 7 with IIS7 but not on windows XP with ISS5.1 The following path "IIS :/ / localhost/W3SVC/AppPools" is different on IIS5.1?
public static CreateAppPool(string name)
{
string machineName = System.Environment.GetEnvironmentVariable("COMPUTERNAME");
DirectoryEntry Service = new DirectoryEntry("IIS://"+machineName+"/W3SVC/AppPools");
// create new app pool
DirectoryEntry appPool = Service.Children.Add(name, "IIsApplicationPool");
appPool.CommitChanges();
Service.CommitChanges();
}
You can't create an application pool in IIS 5, but you can create a new virtual directory under the Default Web site and make it an application.