Copied to clipboard

Flag this post as spam?

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


  • Colin 46 posts 146 karma points
    Mar 31, 2020 @ 17:52
    Colin
    0

    Hi

    My Umbraco installation is as follows

    SiteDefault
      - SiteTwo
      - SiteThree
      - Site Four
    

    I have a web user control. How could I retrieve the root URL for each site please?

    Thanks

  • Colin 46 posts 146 karma points
    Apr 01, 2020 @ 05:35
    Colin
    0

    When I enter this in my control I have a namespace error but I don't know which namespace I need to add. If this is the correct code does anyone know?

    node.UrlAbsolute();

    Thanks

  • Dennis Adolfi 1072 posts 6377 karma points MVP 2x c-trib
    Apr 01, 2020 @ 06:38
    Dennis Adolfi
    0

    Hi Colin.

    Is your 'node' an IPublishedContent item? In that case you can use the extensionmethod .Site() like this:

    node.Site().Url;
    

    For this you need the Umbraco.Web namespace referenced: https://our.umbraco.com/apidocs/v7/csharp/api/Umbraco.Web.PublishedContentExtensions.html

  • Colin 46 posts 146 karma points
    Apr 02, 2020 @ 16:13
    Colin
    0

    Hi Dennis

    I'm trying this but I just can't get it to work on Umbraco 7.

    Word you mind giving me a full example as no matter what I try it didn't work but it would be a published node under the home node.

    OR even better without be to get the URL for the current page?

    Many thanks

  • Yakov Lebski 426 posts 1653 karma points
    Apr 02, 2020 @ 17:03
    Yakov Lebski
    0
    var root=Model.AncestorOrSelf(1)
    
Please Sign in or register to post replies

Write your reply to:

Draft