Created
August 24, 2012 17:03
-
-
Save florisrobbemont/3452940 to your computer and use it in GitHub Desktop.
IIS Binding from c#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get IIS reference (create a reference to Microsoft.Web.Administration) | |
ServerManager serverManager = new ServerManager(); | |
// Create new AppPool or use existing | |
ApplicationPool appPool = serverManager.ApplicationPools.FirstOrDefault(x => x.Name == appPoolName); | |
if (appPool == null) | |
appPool = serverManager.ApplicationPools.Add(appPoolName); | |
// Umbraco is .NET 4.0 | |
appPool.ManagedRuntimeVersion = "v4.0"; | |
// Add site and configure | |
string physicalPath = System.IO.Path.Combine(siteLocation, UmbracoGenerator.Code.Constants.UmbracoRuntimeRelativePath); | |
serverManager.Sites.Add(appPoolName, physicalPath, 80); | |
serverManager.Sites[StartArguments.Name].ApplicationDefaults.ApplicationPoolName = appPoolName; | |
serverManager.Sites[StartArguments.Name].Bindings.Clear(); | |
serverManager.Sites[StartArguments.Name].Bindings.Add("*:80:" + hostName, "http"); | |
serverManager.Sites[StartArguments.Name].ServerAutoStart = true; | |
// Commit | |
serverManager.CommitChanges(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I need to assign a site created a specific user credentials, as I do it??