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.
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.
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:
But why am I getting an error for "guidUdi" here? How can I solve it.
Thank you
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.
Sorry, this is untested as I'm on the move right now.
it worked !!
I can’t thank you enough (:
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.is working on a reply...