/// <summary>
        /// 
        /// </summary>
        /// <param name="port">The application port</param>
        /// <param name="rootWebConfigPath">The to the framework's root web.config based on runtime version</param>
        /// <param name="runtimeVersion">One of the <see><cref>Constants.RuntimeVersion</cref></see> values.</param>
        /// <param name="pipelineMode">One of the <see><cref>Constants.PipelineMode</cref></see> values.</param>
        /// <returns></returns>
        public ConfigSettings Create(uint port, string rootWebConfigPath, string runtimeVersion, string pipelineMode, string userName, string password)
        {
            var settings = new ConfigSettings
            {
                RootWebConfigPath = Environment.ExpandEnvironmentVariables(rootWebConfigPath),
                AppConfigPath = Path.Combine(configPath, "applicationHost.config")
            };

            var clrConfigPath = Path.Combine(configPath, "aspnet.config"); // TODO: might need to just -> runtime version aspnet.config file
            var redirectConfigPath = Path.Combine(configPath, "redirection.config"); // TODO: might need to just -> runtime version redirection.config file

            File.WriteAllText(redirectConfigPath, Resources.redirection);
            File.WriteAllText(clrConfigPath, Resources.aspnet);
            File.WriteAllText(settings.AppConfigPath, runtimeVersion == Constants.RuntimeVersion.VersionFourDotZero ? Resources.applicationhost : Resources.v2_0AppHost);

            // TODO: Randomize AES Session Keys??
            // TODO: Generage new machine key - use BuildMachineKeyElement()
            // TODO: /configuration/system.webServer/security/authentication/anonymousAuthentication[username] = sandbox username or just IUSR?

            var appHostConfig = XDocument.Load(settings.AppConfigPath);

            // set the application pools config files
            var appPoolName = "AppPool" + port;
            appHostConfig.XPathSelectElement(Constants.ConfigXPath.AppPools).RemoveNodes();
            appHostConfig.AddToElement(Constants.ConfigXPath.AppPools,
                BuildApplicationPool(appPoolName, runtimeVersion, pipelineMode, clrConfigPath, userName, password));

            // logging paths
            var iisLogDir = Path.Combine(logsRootPath, "IIS");
            appHostConfig.SetValue(Constants.ConfigXPath.SiteDefaults + "/logFile", "directory", iisLogDir);
            EnsureDirectory(iisLogDir);

            var traceLogDir = Path.Combine(logsRootPath, "TraceLogFiles");
            appHostConfig.SetValue(Constants.ConfigXPath.SiteDefaults + "/traceFailedRequestsLogging", "directory", traceLogDir);
            EnsureDirectory(traceLogDir);

            // add the site and settings to the app host config
            appHostConfig.AddToElement(Constants.ConfigXPath.Sites, BuildSiteElement("IronFoundrySite", webRootPath, appPoolName, port));

            appHostConfig.SetValue(Constants.ConfigXPath.Sites + "/applicationDefaults", "applicationPool", appPoolName);
            appHostConfig.SetValue(Constants.ConfigXPath.Sites + "/virtualDirectoryDefaults", "allowSubDirConfig", true);

            appHostConfig.Save(settings.AppConfigPath);
            return settings;
        }
Exemple #2
0
 public WebServer(ConfigSettings configSettings)
 {
     this.configSettings = configSettings;
 }
Exemple #3
0
 public WebServer(ConfigSettings configSettings)
 {
     this.configSettings = configSettings;
 }