Copied to clipboard

Flag this post as spam?

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

  • Manish 373 posts 929 karma points
    May 31, 2016 @ 11:39

    Getting full url by node id


    I am using

     var path = umbraco.library.NiceUrlWithDomain(Convert.ToInt32(nodeId));

    To get full path of a particular node. My question is that How can i handle the situation in which nodeid is incorrect ?

    Or is there any way to get full url by nodeid. please help me on this .


  • Dan Diplo 1543 posts 6098 karma points MVP 4x c-trib
    May 31, 2016 @ 12:12
    Dan Diplo

    You are using the old, deprecated API. With the new API you have a couple of choices:

    var path = Umbraco.Url(nodeId, UrlProviderMode.Absolute);

    (You'll need to add a reference to Umbraco.Web.Routing).

    If the nodeId doesn't exist then path will equal "#" so you can check for that.

    Or you could use:

    var node = Umbraco.TypedContent(nodeId);
    if (node != null)
        string path = node.UrlAbsolute();
  • Manish 373 posts 929 karma points
    May 31, 2016 @ 12:18

    Thanks Dan

  • Harikrishna Parmar 31 posts 207 karma points c-trib
    Feb 24, 2020 @ 04:18
    Harikrishna Parmar

    Umbraco 8 :

    var content = Umbraco.Content(Id); var url=content.Url(string culture = null, UrlMode mode = UrlMode.Auto);

Please Sign in or register to post replies

Write your reply to: