Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi - I have a partial view to render an IPublishedElement model, but also need to show content from the current page (IPublishedContent). Can i obtain the current IPC from the DI container?
this is what i tried but it doesn't work:
@inject UmbracoHelper UmbracoHelper
var ipc = UmbracoHelper.AssignedContentItem;
so i managed to find this technique which seems to give me what im after:
@inject IUmbracoContextAccessor umbracoContext
var currentPage = umbracoContext.GetRequiredUmbracoContext().PublishedRequest.PublishedContent;
But still keen to hear thoughts on if this is an antipattern/bad practice and why, or if there is a better way.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted