Copied to clipboard

Flag this post as spam?

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


  • diojen 3 posts 83 karma points
    1 week ago
    diojen
    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 2977 posts 12925 karma points MVP 5x admin c-trib
    1 week ago
    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.

  • diojen 3 posts 83 karma points
    1 week ago
    diojen
    0

    it worked !!

    I can’t thank you enough (:

  • Jeavon Leopold 2977 posts 12925 karma points MVP 5x admin c-trib
    1 week ago
    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.

Please Sign in or register to post replies

Write your reply to:

Draft