Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Martin 5 posts 85 karma points
    Oct 07, 2015 @ 13:48

    getting the domains of a content node

    enter image description here

    Umbraco version: 7.3

    I have an issue that i am unable to solve. I noticed that some of my code is marked as obsolete and that i need to use the DomainService instead of using "umbraco.library.GetCurrentDomains(nodeid);"

    I only want the domains belonging to a certain node, not all domains. DomainService.GetAssignedDomains (nodeid, false); returns nothing.

    I am calling this code from a surfacecontroller using ApplicationContext.Services.DomainService.GetAssignedDomains.

    I really have no clue how to go about this. How am i supposed to get the domains belonging to a given node from inside a surfacecontroller?

    Any help is appreciated :)

  • Sebastiaan Janssen 4880 posts 14554 karma points MVP admin hq
    Oct 08, 2015 @ 11:54
    Sebastiaan Janssen

    It seems like you're more interested in the language than the domain?

    How about:

    var content = Umbraco.TypedContent(nodeId);
    var culture = content.GetCulture();

    Which will give you all the info below. Would that work for you?

    enter image description here

  • Caglar Tasci 14 posts 120 karma points
    Nov 06, 2016 @ 10:41
    Caglar Tasci

    Dear Sebastiaan,

    i am building an Umbraco multisite project. The nodes are created dynamically and i have to assign different domains for the particular root node. I creat the node like this:

       var contentService = ApplicationContext.Current.Services.ContentService;
       var office = contentService.CreateContent(officename, -1, "home", 0);

    How can i now assign the hosting/ domain information ? Unfortunately i could not find any documentation for the domainservice or something near it.

    Thank you for your help

  • ssougnez 86 posts 290 karma points c-trib
    Sep 11, 2018 @ 11:43

    I know this topic is old but I was looking for the same thing today and came up with something so, it might be interesting for other people. I used the following code to do what you asked:

    var language = ApplicationContext.Current.Services.LocalizationService.GetLanguageByIsoCode("en-US");
    ApplicationContext.Current.Services.DomainService.Save(new UmbracoDomain("*" + office.Id)
          LanguageId = language.Id,
          RootContentId = office.Id
Please Sign in or register to post replies

Write your reply to: