MediaService.Saved is not triggering when debugging
I'm working with load balancing servers and making sure the content in Umbraco matches across both servers. I have no problems with saving my Views and Partials Views to both servers by using an Application Event Handler such as
However, it doesn't appear to work the same with when I save images using something like this
MediaService.Saved += MediaServiceSaved;
private void MediaServiceSaved(IMediaService sender, SaveEventArgs<IMedia> e)
{
foreach (var savedMedia in e.SavedEntities)
{
var path = savedMedia.GetValue<string>("umbracoFile");
var filePath = ReturnFilePathFromJsonPath(path);
SaveToServers(filePath);
SaveToServers(filePath.Replace(".jpg", "_thumb.jpg"));
}
}
When I set up a breakpoint at my TemplateSaved method, the breakpoint hits whenever I make a change to my template. From there I can walk through my code and make sure the template saves to both servers. However when I go to add an image or delete and remove one, it does not hit the MediaServiceSaved method as I had expected it to. Am i using the correct Event Handler for saving images?
When in a load balanced configuration you need to use Cache events as these will be triggered on all servers unlike normal events (ContentService etc..) that will occur only on the publishing server.
These are the most commonly used events (there are plenty of others) as they cover content changes:
MediaService.Saved is not triggering when debugging
I'm working with load balancing servers and making sure the content in Umbraco matches across both servers. I have no problems with saving my Views and Partials Views to both servers by using an Application Event Handler such as
However, it doesn't appear to work the same with when I save images using something like this
When I set up a breakpoint at my TemplateSaved method, the breakpoint hits whenever I make a change to my template. From there I can walk through my code and make sure the template saves to both servers. However when I go to add an image or delete and remove one, it does not hit the MediaServiceSaved method as I had expected it to. Am i using the correct Event Handler for saving images?
Thanks
Hi Daniel,
When in a load balanced configuration you need to use Cache events as these will be triggered on all servers unlike normal events (ContentService etc..) that will occur only on the publishing server.
These are the most commonly used events (there are plenty of others) as they cover content changes:
Jeavon
This isn't on a load balanced server yet. This is just running locally. I'm looking to trigger the MediaServiceSaved event when running locally.
is working on a reply...