Correct usage of EnsurePublishedContentRequestAttribute
Hi all,
I'm currently running into the following error when trying to access the rich text property of blog posts containing a macro.
Cannot render a macro when there is no current PublishedContentRequest.
After a quick search on the forums I found a post in which a user is having a similar issue-
accessing RTE with Macro Error
After reading the post it seems the best way to fix this is to use the EnsurePublishedContentRequestAttribute - the only problem is I'm not completely sure how to use it and I couldn't find a sample anywhere. If anyone could point me in the right direction that would be great!
Here's a cut down version of my umbraco api controller - I'm running Umbraco 7.3.0
[HttpGet]
public async Task<IHttpActionResult>GetBlogs()
{
var response = UmbracoContext.ContentCache.GetById(258).Children
.ToList();
var blogs = response.Select(item => new Blog()
{
PostBody = item.GetPropertyValue<string>("bodyContent") //throws Cannot render a macro when there is no current PublishedContentRequest.
}).ToList();
return OK(blogs)
}
Correct usage of EnsurePublishedContentRequestAttribute
Hi all,
I'm currently running into the following error when trying to access the rich text property of blog posts containing a macro.
After a quick search on the forums I found a post in which a user is having a similar issue- accessing RTE with Macro Error
After reading the post it seems the best way to fix this is to use the EnsurePublishedContentRequestAttribute - the only problem is I'm not completely sure how to use it and I couldn't find a sample anywhere. If anyone could point me in the right direction that would be great!
Here's a cut down version of my umbraco api controller - I'm running Umbraco 7.3.0
Thanks
is working on a reply...