Copied to clipboard

Flag this post as spam?

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


  • paco 25 posts 155 karma points
    Jul 25, 2019 @ 12:53
    paco
    0

    umbraco library niceurlwithdomain and niceurl in Umbraco 8.1

    Hello,

    I have already installed Umbraco 8.1 locally and I am doing a porting from an Umbraco 7.5 site.

    This site has a code like this:

    Uri uri = new Uri(umbraco.library.NiceUrlWithDomain(pageId).ToString());
    

    and also this:

    return umbraco.library.NiceUrl(id);
    

    that, obiouvsly, does not work on Umbraco 8.1.

    How can I replace them in Umbraco 8.1 to obtain the same behavior?

    Thanks

  • Marc Goodson 2157 posts 14435 karma points MVP 9x c-trib
    Jul 27, 2019 @ 08:08
    Marc Goodson
    1

    Hi Paco

    Have you tried:

      var urlWithDomain = Umbraco.Content(id)?.Url(mode: UrlMode.Absolute);
    

    setting the mode to be Absolute will return the domain along with the Url.

    and for the nice url...

     var relativeNiceUrl = Umbraco.Content(id)?.Url();
    

    regards

    Marc

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies