The following example adds a domain alias to a site.
privatebool AddDomainAliasToSite() { // Get the site object SiteInfo site = SiteInfoProvider.GetSiteInfo("MyNewSite"); if (site != null) { // Create new site domain alias object SiteDomainAliasInfo newAlias = newSiteDomainAliasInfo();
// Set the properties newAlias.SiteDomainAliasName = "127.0.0.1"; newAlias.SiteID = CMSContext.CurrentSiteID; // Save the site domain alias SiteDomainAliasInfoProvider.SetSiteDomainAliasInfo(newAlias); returntrue; } returnfalse; }
The following example removes a domain alias from a site.
privatebool DeleteSiteDomainAlias() { // Get the site object SiteInfo si = SiteInfoProvider.GetSiteInfo("MyNewSite"); if (si != null) {
// Get the site domain alias SiteDomainAliasInfo deleteAlias = SiteDomainAliasInfoProvider.GetSiteDomainAliasInfo("127.0.0.1", si.SiteID);
// Delete the site domain alias SiteDomainAliasInfoProvider.DeleteSiteDomainAliasInfo(deleteAlias); return (deleteAlias != null); } returnfalse; }