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, how would one get the ContentModel (or IPublishedContent) in a ViewComponent?
Hi Roy,
This is an example of getting current page published content model in ViewComponent class:
public class MetaDataViewComponent : ViewComponent { private IUmbracoContextAccessor _context; public MetaDataViewComponent(IUmbracoContextAccessor context) { _context = context; } public async Task<IViewComponentResult> InvokeAsync() { var content = _context.GetRequiredUmbracoContext().PublishedRequest.PublishedContent; return View(model); } }
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Umbraco 9: Get ContentModel in a ViewComponent
Hi, how would one get the ContentModel (or IPublishedContent) in a ViewComponent?
Hi Roy,
This is an example of getting current page published content model in ViewComponent class:
is working on a reply...