Copied to clipboard

Flag this post as spam?

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


  • Aung Zin Phyo 17 posts 87 karma points
    Jan 09, 2020 @ 08:16
    Aung Zin Phyo
    0
            var udi = Udi.Parse(test);
            var page = Services.ContentService.GetById(Guid.Parse("ac0a00738fbb43d3b6ebd01928d61051"));
            string teee = page.GetValue("CarDetailsTitle").ToString();
    
  • Joep 96 posts 698 karma points
    Jan 11, 2020 @ 11:46
    Joep
    0

    Hi,

    Why would you need to convert the UDI to a Guid? You can just do a getbyid with a UDI.

    -Joep

  • Heather Floyd 604 posts 1002 karma points MVP 5x c-trib
    Sep 16, 2020 @ 18:10
    Heather Floyd
    1

    Actually, in order to use the ContentService/MediaService, you can't just pass in a UDI, you need to convert it to a GuidUdi first. See: UDI and ContentService / GetValue<>

  • Laurent Lequenne 122 posts 247 karma points
    Oct 12, 2023 @ 09:55
    Laurent Lequenne
    0

    new GuidUdi(new Uri(thisUDIAsString)).Guid

  • Enkosi 11 posts 86 karma points
    Dec 14, 2020 @ 12:50
    Enkosi
    1

    For anyone who lands here searching for how to get the UDI you can do the following:

    var udi = new GuidUdi(node.ContentType.ItemType.ToString(), node.Key);
    

    Otherwise, you can simply use the UmbracoHelper to get published content:

    var page = Umbraco.Web.Composing.Current.UmbracoHelper.Content(int Id);
    

    Please note there are method overrides for Content so you can get Content by:

    • Udi
    • string
    • int
    • object

    I hope that helps.

Please Sign in or register to post replies

Write your reply to:

Draft