Example #1
0
        private WebSite SetupWebsiteTest(ServerManager serverManager)
        {
            // Add website to table storage
            var website = new WebSite
            {
                Name        = "test",
                Description = "Test website"
            };
            var binding = new Binding {
                HostName = "test.com", Port = 80, Protocol = "http"
            };

            _repo.CreateWebSiteWithBinding(website, binding);
            website.Bindings = new[] { binding };

            // Add role website to IIS / wwwroot directory
            serverManager.Sites.Add(RoleWebsiteName, "http", "*:80:test", Path.Combine(_sitePath, "deployment"));
            Directory.CreateDirectory(Path.Combine(_sitePath, RoleWebsiteName.Replace("-", ".").ToLowerInvariant()));
            serverManager.CommitChanges();

            GetBlobContainer().Delete();

            return(website);
        }
        public ActionResult Create(CreateWebSiteViewModel model)
        {
            if (!ModelState.IsValid)
                return View(model);

            var site = new WebSite
            {
                Name = model.Name,
                Description = model.Description,
                EnableCDNChildApplication = model.EnableCDNChildApplication,
                EnableTestChildApplication = model.EnableTestChildApplication
            };
            _webSiteRepository.CreateWebSite(site);
            if (model.AddStandardBindings)
            {
                var http = new Binding
                {
                    HostName = model.HostName,
                    Port = 80,
                    Protocol = "http",
                    IpAddress = "*",
                    CertificateThumbprint = ""
                };
                var https = new Binding
                {
                    HostName = model.HostName,
                    Port = 443,
                    Protocol = "https",
                    IpAddress = "*",
                    CertificateThumbprint = ""
                };
                _webSiteRepository.AddBindingToWebSite(site.Id, http);
                _webSiteRepository.AddBindingToWebSite(site.Id, https);
            }

            return RedirectToAction("Detail", new {area = ControlPanelAreaRegistration.Name, site.Id});
        }
        private WebSite CreateWebSiteWithBindings(int nbindings)
        {
            var id = Guid.NewGuid();
            var bindings = new List<Binding>();

            var site = new WebSite(id)
            {
                Name = "Test Web Site " + id.ToString(),
                Description = "Description Test Web Site " + id.ToString()
            };

            var binding = new Binding
            {
                Protocol = "http",
                IpAddress = string.Empty,
                Port = 80,
                HostName = "www.test0.com"
            };

            _repository.CreateWebSiteWithBinding(site, binding);
            bindings.Add(binding);

            for (var k = 1; k < nbindings; k++)
            {
                var otherBinding = new Binding
                {
                    Protocol = "http",
                    IpAddress = string.Empty,
                    Port = 80 + k,
                    HostName = string.Format("www.test{0}.com", k)
                };

                _repository.AddBindingToWebSite(site.Id, otherBinding);
                bindings.Add(otherBinding);
            }

            site.Bindings = bindings;

            return site;
        }
        private static bool AreEqualsBindings(Microsoft.Web.Administration.Binding iisBinding, Binding binding)
        {
            var bindingAdress = binding.IpAddress == "*" ? "0.0.0.0" : binding.IpAddress;

            return
                iisBinding.Protocol.Equals(binding.Protocol, StringComparison.OrdinalIgnoreCase) &&
                iisBinding.EndPoint.Address.ToString().Equals(bindingAdress, StringComparison.OrdinalIgnoreCase) &&
                iisBinding.EndPoint.Port == binding.Port &&
                iisBinding.Host.Equals(binding.HostName, StringComparison.OrdinalIgnoreCase);
        }
Example #5
0
        private static bool AreEqualsBindings(Microsoft.Web.Administration.Binding iisBinding, Binding binding)
        {
            var bindingAdress = binding.IpAddress == "*" ? "0.0.0.0" : binding.IpAddress;

            return
                (iisBinding.Protocol.Equals(binding.Protocol, StringComparison.OrdinalIgnoreCase) &&
                 iisBinding.EndPoint.Address.ToString().Equals(bindingAdress, StringComparison.OrdinalIgnoreCase) &&
                 iisBinding.EndPoint.Port == binding.Port &&
                 iisBinding.Host.Equals(binding.HostName, StringComparison.OrdinalIgnoreCase));
        }
        private WebSite SetupWebsiteTest(ServerManager serverManager)
        {
            // Add website to table storage
            var website = new WebSite
            {
                Name = "test",
                Description = "Test website"
            };
            var binding = new Binding { HostName = "test.com", Port = 80, Protocol = "http" };
            _repo.CreateWebSiteWithBinding(website, binding);
            website.Bindings = new[] { binding };

            // Add role website to IIS / wwwroot directory
            serverManager.Sites.Add(RoleWebsiteName, "http", "*:80:test", Path.Combine(_sitePath, "deployment"));
            Directory.CreateDirectory(Path.Combine(_sitePath, RoleWebsiteName.Replace("-", ".").ToLowerInvariant()));
            serverManager.CommitChanges();

            GetBlobContainer().Delete();

            return website;
        }
 public void EditBinding(Binding binding)
 {
     _bindingTable.AddOrUpdate(binding.ToRow());
 }
        public void CreateWebSiteWithBinding(WebSite webSite, Binding binding)
        {
            binding.WebSiteId = webSite.Id;

            _webSiteTable.Add(webSite.ToRow());
            _bindingTable.Add(binding.ToRow());
        }
 public void AddBindingToWebSite(WebSite webSite, Binding binding)
 {
     binding.WebSiteId = webSite.Id;
     _bindingTable.Add(binding.ToRow());
 }