Delete media with MediaService keeps showing as IPublishedContent
Hi,
I run into an issue where I delete a media item by code and is still shows up if I query for IPublishedContent.
I have the following code for deleting a media node:
_mediaService.Delete(nodeToDelete)
_mediaService is just the normal Umbraco MediaService.
The media item is deleted in Umbraco, all seems to work fine.
But when I query for media using the UmbracoHelper TypedMediaAtRoot my deleted media item still shows up. After I republish the entire site the cache is updated and it all works fine. I don't want te republish the site after every media item I delete. What is the best way of doing this?
Code I use to query the media after I deleted the file (using the normal UmbracoHelper).
For more information on how to use this or what's available to you, download the source code for the relevant version of Umbraco you're using and look in the 'Umbraco.Core' project and you'll see a folder called 'Services'
Delete media with MediaService keeps showing as IPublishedContent
Hi,
I run into an issue where I delete a media item by code and is still shows up if I query for IPublishedContent.
I have the following code for deleting a media node:
_mediaService is just the normal Umbraco MediaService.
The media item is deleted in Umbraco, all seems to work fine.
But when I query for media using the UmbracoHelper TypedMediaAtRoot my deleted media item still shows up. After I republish the entire site the cache is updated and it all works fine. I don't want te republish the site after every media item I delete. What is the best way of doing this?
Code I use to query the media after I deleted the file (using the normal UmbracoHelper).
What version of Umbraco are you using?
From version 6.x, you could try using the ContentService class which has a number of methods available for managing content.
An example usage would be:
ApplicationContext.Current.Services.ContentService.MoveToRecycleBin(Content)
or if you wanted to remove it and all of it's children:
ApplicationContext.Current.Services.ContentService.Delete(Content)
For more information on how to use this or what's available to you, download the source code for the relevant version of Umbraco you're using and look in the 'Umbraco.Core' project and you'll see a folder called 'Services'
Hope this helps!
is working on a reply...