Using v.7.10 and I have wired up content service published event however it never fires. Content does publish and gatheringnode event which is wired up in same class also fires. Any ideas?
My code looks like:
public class Events : IApplicationEventHandler
{
void ContentService_Published(Umbraco.Core.Publishing.IPublishingStrategy sender, Umbraco.Core.Events.PublishEventArgs<Umbraco.Core.Models.IContent> e)
{
LogHelper.Info<string>("published settings object");
//if content being published is sitesettings we need to restart app pool
//else our settings changes will not be picked up
if (e.PublishedEntities.Count() == 1 && e.PublishedEntities.First().ContentType.Alias == "SiteSettingDocType")
{
Restart();
}
}
private static void Restart()
{
//restart web app (instead of iisreset)
DirectoryInfo dir = new DirectoryInfo(HttpContext.Current.Server.MapPath("restart"));
if (dir.Exists)
{
Directory.Move(dir.FullName, dir.FullName + "ed");
}
else
{
DirectoryInfo dired = new DirectoryInfo(HttpContext.Current.Server.MapPath("restarted"));
if (dired.Exists)
{
Directory.Move(dired.FullName, dir.FullName);
}
else
{
Directory.CreateDirectory(dir.FullName);
}
}
}
public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
ContentService.Published += ContentService_Published;
}
public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
{
}
}
Ok so in answer to my own question i was being dumb. In my web.config debug was set to false i set it to true and found i could now debug and figure out what issues in my code. Weird thing is i was with debug set to false able to debug razor macros?? Weirdness.
Content published event not firing
Guys,
Using v.7.10 and I have wired up content service published event however it never fires. Content does publish and gatheringnode event which is wired up in same class also fires. Any ideas?
My code looks like:
Ok so in answer to my own question i was being dumb. In my web.config debug was set to false i set it to true and found i could now debug and figure out what issues in my code. Weird thing is i was with debug set to false able to debug razor macros?? Weirdness.
Ismail
Hi Ismail,
When the event will be fired:
exactly before node will be published or after?
And How can I access the node values to set a particular value?
Thanks
is working on a reply...