Copied to clipboard

Flag this post as spam?

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


  • Dervis 17 posts 147 karma points
    Sep 13, 2018 @ 14:42
    Dervis
    0

    The name 'guidUdi' does not exist in the current context

    hi everyone,

    I'm beginning level for umbraco. I am trying to carry on a project that was already done and things are bad. I use umb // media / .. ads6a56fa5d6s .. to draw some pictures from another page. I read it elsewhere this solving:

    // Your string which is retrieved from Archetype.
    var imageString = "umb://media/c33bfe07a82b4df18a79db154139cb91";
    
    // Get the guid from this string.
    var imageGuidUdi = GuidUdi.Parse(imageString);
    
    // Get the ID of the node!
    var imageNodeId = ApplicationContext.Current.Services.EntityService.GetIdForKey(guidUdi.Guid, (UmbracoObjectTypes)Enum.Parse(typeof(UmbracoObjectTypes), guidUdi.EntityType, true));
    
    // Finally, get the node.
    var imageNode = Umbraco.TypedMedia(imageNodeId.Result);
    

    But why am I getting an error for "guidUdi" here? How can I solve it.

    Thank you

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Sep 13, 2018 @ 15:00
    Jeavon Leopold
    100

    I think you can pass the Guid into the TypeContent method, you certainly shouldn't ever need to use a management service for rendering.

    e.g.

    var imageGuidUdi = GuidUdi.Parse(imageString).Guid;
    var imageNode = Umbraco.TypedContent(imageGuidUdi);
    

    Sorry, this is untested as I'm on the move right now.

  • Dervis 17 posts 147 karma points
    Sep 14, 2018 @ 06:51
    Dervis
    0

    it worked !!

    I can’t thank you enough (:

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Sep 14, 2018 @ 09:17
    Jeavon Leopold
    0

    No problem! As I said before if you ever find yourself using ApplicationContext.Current.Services for rendering content then something is wrong and there will be a different approach that you will need to find.

  • 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