简体   繁体   中英

Why are ASP.NET settings not showing up when I use ServerManager to create site in IIS?

When I create my site using ServerManager for some reason the asp.net settings are not showing up in IIS, but if I manually create the site and point it at the directory everything works fine a I get all the settings. I have been searching for hours trying to figure out what I am doing wrong with no luck.

Here is my code

int sleep = 3000;

Console.WriteLine(@"Installing Connections AD Sync UI\Services...");

//Extract Files
Console.WriteLine(@"Extracting required files...");
FileInfo info = new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location);
System.IO.File.WriteAllBytes(info.DirectoryName + @"\Payload.zip", ConnectionsADSyncInstaller.Properties.Resources.ConnectionsADSync);
ZipFile.ExtractToDirectory(info.DirectoryName + @"\Payload.zip", info.DirectoryName);
File.Delete(info.DirectoryName + @"\Payload.zip");

Thread.Sleep(sleep);


//Create IIS Site/Settings
ServerManager iisManager = new ServerManager();
Console.WriteLine("Setting up IIS application pool...");
ApplicationPool myApp = iisManager.ApplicationPools.Add("ConnectionsADSync");
myApp.
myApp.AutoStart = true;
myApp.ManagedPipelineMode = ManagedPipelineMode.Integrated;
myApp.ManagedRuntimeVersion = "V4.0";
myApp.ProcessModel.IdentityType = ProcessModelIdentityType.ApplicationPoolIdentity;
myApp.Enable32BitAppOnWin64 = true; //unsure...
Console.WriteLine("Configuring ConnectionsADSync web site in IIS...");

iisManager.CommitChanges();
Thread.Sleep(sleep);



//Give AppPool user permissions
Console.WriteLine("Configuring folder permissions for IIS application pool...");
DirectoryInfo myDirectoryInfo = new DirectoryInfo(info.DirectoryName + @"\ConnectionsADSync\ConnectionsADSyncWeb");
DirectorySecurity myDirectorySecurity = myDirectoryInfo.GetAccessControl();
myDirectorySecurity.AddAccessRule(new FileSystemAccessRule(@"IIS APPPOOL\ConnectionsADSync", FileSystemRights.ReadAndExecute, AccessControlType.Allow));
myDirectoryInfo.SetAccessControl(myDirectorySecurity);

Thread.Sleep(sleep);

//Create the site
Site newSite = iisManager.Sites.Add("ConnectionsADSync", info.DirectoryName + @"\ConnectionsADSync\ConnectionsADSyncWeb", 8089);//D:\\ConnectionsADSync
newSite.ApplicationDefaults.ApplicationPoolName = "ConnectionsADSync";
newSite.ServerAutoStart = true;

iisManager.CommitChanges();
Thread.Sleep(sleep);

//Install Service
Console.WriteLine("Installing ConnectionsADSyncService (Windows Service)...");
Process proc = Process.Start(info.DirectoryName + @"\ConnectionsADSync\ConnectionsADSyncService\installer.bat");
proc.WaitForExit();
ServiceController service = new ServiceController("~ConnectionSyncServer");
service.Start();

Thread.Sleep(sleep);


Console.WriteLine("Installation complete, press Enter to exit");
Console.ReadLine();
enter code here

ApplicationDefaults is not the right place to set the pool for your web site.

Find the root application from Site.Applications whose path is "/" and then set its ApplicationPoolName to the pool you created earlier.

That can help you associate the proper application pool and it will work just like what you created in IIS Manager.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM