Search code examples
apiumbraco

Umbraco: Manage hostnames programmatically through the API


Does anyone know of a way to manage Hostnames programmatically for Umbraco IContent objects ?

I need to import a whole site from a csv and I need to set the Hostnames from code automatically.

Thanks !


Solution

  • Perhaps something like this will help you?

    var domain = new umbraco.cms.businesslogic.web.Domain("example.com")
                     {
                         RootNodeId = 1078,
                         Language = Language.GetByCultureCode("en-GB"),
                     };
    domain.Save();