public static IIS.Site Add(this IIS.SiteCollection siteCollection, string name, string bindingInformation, string physicalPath, byte[] certificateHash, SslFlags sslFlags)
        {
            var site = siteCollection.Add(name, bindingInformation, physicalPath, certificateHash);

            SetSslFlags(site.Bindings.First(), sslFlags);

            return(site);
        }
Beispiel #2
0
        internal Site(ConfigurationElement element, SiteCollection parent)
            : base(element, "site", null, parent, null, null)
        {
            ApplicationDefaults = ChildElements["applicationDefaults"] == null
                ? new ApplicationDefaults(parent.ChildElements["applicationDefaults"], this)
                : new ApplicationDefaults(ChildElements["applicationDefaults"], this);
            Parent   = parent;
            Bindings = new BindingCollection(ChildElements["bindings"], this);
            if (element == null)
            {
                return;
            }

            foreach (ConfigurationElement node in (ConfigurationElementCollection)element)
            {
                var app = new Application(node, Applications);
                Applications.InternalAdd(app);
            }
        }
Beispiel #3
0
 internal Site(SiteCollection parent)
     : this(null, parent)
 {
 }
        private void Initialize()
        {
            if (this.Initialized)
            {
                return;
            }

            this.Initialized = true;
            PreInitialize();
            var machineConfig = Helper.IsRunningOnMono()
                ? "/Library/Frameworks/Mono.framework/Versions/Current/etc/mono/4.5/machine.config"
                : Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.Windows),
                "Microsoft.NET",
                IntPtr.Size == 2 ? "Framework" : "Framework64",
                "v4.0.30319",
                "config",
                "machine.config");
            var machine =
                new Configuration(
                    new FileContext(
                        this,
                        machineConfig,
                        null,
                        null,
                        false,
                        true,
                        true));
            var webConfig = Helper.IsRunningOnMono()
                ? "/Library/Frameworks/Mono.framework/Versions/Current/etc/mono/4.5/web.config"
                : Path.Combine(
                Environment.GetFolderPath(Environment.SpecialFolder.Windows),
                "Microsoft.NET",
                IntPtr.Size == 2 ? "Framework" : "Framework64",
                "v4.0.30319",
                "config",
                "web.config");
            var web =
                new Configuration(
                    new FileContext(
                        this,
                        webConfig,
                        machine.FileContext,
                        null,
                        false,
                        true,
                        true));

            _applicationHost =
                new Configuration(
                    new FileContext(this, this.FileName, web.FileContext, null, true, false, this.ReadOnly));

            this.LoadCache();

            var poolSection = _applicationHost.GetSection("system.applicationHost/applicationPools");

            _applicationPoolDefaults =
                new ApplicationPoolDefaults(poolSection.GetChildElement("applicationPoolDefaults"), poolSection);
            this.ApplicationPoolCollection = new ApplicationPoolCollection(poolSection, this);
            var siteSection = _applicationHost.GetSection("system.applicationHost/sites");

            _siteDefaults        = new SiteDefaults(siteSection.GetChildElement("siteDefaults"), siteSection);
            _applicationDefaults = new ApplicationDefaults(
                siteSection.GetChildElement("applicationDefaults"),
                siteSection);
            _virtualDirectoryDefaults =
                new VirtualDirectoryDefaults(siteSection.GetChildElement("virtualDirectoryDefaults"), siteSection);
            this.SiteCollection = new SiteCollection(siteSection, this);

            PostInitialize();
        }
        private void Initialize()
        {
            lock (_locker)
            {
                if (Initialized)
                {
                    return;
                }

                Initialized = true;
                PreInitialize();

                var machine =
                    new Configuration(
                        new FileContext(
                            this,
                            Helper.FileNameMachineConfig,
                            null,
                            null,
                            false,
                            true,
                            true)
                {
                    IgnoreSchemaCheck = true
                });

                _web =
                    new Configuration(
                        new FileContext(
                            this,
                            Helper.FileNameWebConfig,
                            machine.FileContext,
                            null,
                            false,
                            true,
                            false));

                _applicationHost =
                    new Configuration(
                        new FileContext(this, FileName, _web.FileContext, null, true, false, ReadOnly));

                LoadCache();

                var poolSectionName = "system.applicationHost/applicationPools";
                var poolSection     = _applicationHost.GetSection(poolSectionName);
                if (poolSection == null)
                {
                    throw new COMException($"Filename: \\\\?\\{FileName}\r\nError: The configuration section '{poolSectionName}' cannot be read because it is missing a section declaration\r\n\r\n");
                }

                _applicationPoolDefaults =
                    new ApplicationPoolDefaults(poolSection?.GetChildElement("applicationPoolDefaults"), poolSection);
                ApplicationPoolCollection = new ApplicationPoolCollection(poolSection, this);

                var siteSectionName = "system.applicationHost/sites";
                var siteSection     = _applicationHost.GetSection(siteSectionName);
                if (siteSection == null)
                {
                    throw new COMException($"Filename: \\\\?\\{FileName}\r\nError: The configuration section '{siteSectionName}' cannot be read because it is missing a section declaration\r\n\r\n");
                }

                _siteDefaults        = new SiteDefaults(siteSection?.GetChildElement("siteDefaults"), siteSection);
                _applicationDefaults = new ApplicationDefaults(
                    siteSection?.GetChildElement("applicationDefaults"),
                    siteSection);
                _virtualDirectoryDefaults =
                    new VirtualDirectoryDefaults(siteSection?.GetChildElement("virtualDirectoryDefaults"), siteSection);
                SiteCollection = new SiteCollection(siteSection, this);
            }

            // IMPORTANT: out of locking for Jexus web server.
            PostInitialize();
        }