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 932 karma points
    May 31, 2016 @ 11:39
    Manish
    2

    Getting full url by node id

    Hi

    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 .

    Manish

  • Dan Diplo 1554 posts 6205 karma points MVP 6x c-trib
    May 31, 2016 @ 12:12
    Dan Diplo
    110

    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 932 karma points
    May 31, 2016 @ 12:18
    Manish
    0

    Thanks Dan

  • Harikrishna Parmar 43 posts 262 karma points c-trib
    Feb 24, 2020 @ 04:18
    Harikrishna Parmar
    0

    Umbraco 8 :

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

  • 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