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,
So I'm catching the Published event just like in the documentation - https://our.umbraco.com/documentation/reference/events/contentservice-events
But when trying to do something like this on a newly created node:
var publishedNode = UmbracoContext.Current.ContentCache.GetById(node.Id);
I get a null back from the ContentCache.GetById?
Why is the node not in the content cache?
Hi Tom, is the node published and the nodeId correct?
If yes, maybe there is an cache issue. Republish entire site and try again.
Best, Sören
Yes the node id comes from PublishEventArgs parameter in the Published event.
Shouldn't the content cache get updated before hitting the Published event?
Hi Tom, the content cache is updated if the node is published. Can you show me more code of the specific method?
private void ContentServicePublished(IPublishingStrategy sender, PublishEventArgs<IContent> args) { foreach (var node in args.PublishedEntities) { if (node.ContentType.Alias == "newsItem") { var publishedNode = UmbracoContext.Current.ContentCache.GetById(node.Id); var nodeUrl = new Uri(helper.UrlAbsolute(node.Id)); }}}
Here publishedNode is null, if its the first time publishing the node.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
ContentService.Published - Can't get node from contentcache
Hi,
So I'm catching the Published event just like in the documentation - https://our.umbraco.com/documentation/reference/events/contentservice-events
But when trying to do something like this on a newly created node:
I get a null back from the ContentCache.GetById?
Why is the node not in the content cache?
Hi Tom, is the node published and the nodeId correct?
If yes, maybe there is an cache issue. Republish entire site and try again.
Best, Sören
Yes the node id comes from PublishEventArgs parameter in the Published event.
Shouldn't the content cache get updated before hitting the Published event?
Hi Tom, the content cache is updated if the node is published. Can you show me more code of the specific method?
Here publishedNode is null, if its the first time publishing the node.
is working on a reply...