I have a member area on a v4.7.1 website where members can delete data from their part of a website. The code I have is working - it deletes the chosen node from the content tree when the form is submitted by the member. However, I don't seem to be able to clear the cache once the node has been deleted. The node gets deleted in the content section of the CMS but it still appears in the front-end view of nodes, even after refreshing the page (rendered via an XSLT macro). So it would appear that the XML cache isn't being regenerated correctly. I'm calling 'Document.RePublishAll()' which I thought would work, but it doesn't. Funnily enough though doing a 'republish entire site' from the Umbraco content section does work.
The code I have is:
int nodeId = Int32.Parse(nodeIdToEdit);
var node = new Node(nodeId);
Document pageToDelete = new Document(nodeId);
if (umbraco.library.HasAccess(node.Id, node.Path))
{
User u = new User(1);
pageToDelete.delete();
//Inform the cache it should update
umbraco.library.UpdateDocumentCache(pageToDelete.Id); // This doesn't seem to clear the cache
Document.RePublishAll(); // This doesn't seem to clear the cache either
}
Can anyone suggest how to ensure that the XML cache is refreshed once the deletion is complete?
Clear cache programmatically after deleting node
Hi,
I have a member area on a v4.7.1 website where members can delete data from their part of a website. The code I have is working - it deletes the chosen node from the content tree when the form is submitted by the member. However, I don't seem to be able to clear the cache once the node has been deleted. The node gets deleted in the content section of the CMS but it still appears in the front-end view of nodes, even after refreshing the page (rendered via an XSLT macro). So it would appear that the XML cache isn't being regenerated correctly. I'm calling 'Document.RePublishAll()' which I thought would work, but it doesn't. Funnily enough though doing a 'republish entire site' from the Umbraco content section does work.
The code I have is:
Can anyone suggest how to ensure that the XML cache is refreshed once the deletion is complete?
Thanks
Ah-ha! Just found this post http://our.umbraco.org/forum/developers/api-questions/29987-Deleting-nodes-programmatically which solves it.
Needed to use 'umbraco.library.RefreshContent();'. No need for Document.RePublishAll().
Thanks ,It's Works!
is working on a reply...