Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Mike Chambers 636 posts 1253 karma points c-trib
    Nov 20, 2012 @ 17:06
    Mike Chambers
    0

    ApplicationStartupHandler has been deprecated.... in 4.10

    could someone confirm if this is the correct way to hook up custom logic to document handlers in v4.10

     

    public class SetDefaultsHandler : IApplicationEventHandler
        {
    
            public void OnApplicationInitialized(UmbracoApplication httpApplication, ApplicationContext applicationContext)
            {
                //your code here
            }
    
            public void OnApplicationStarting(UmbracoApplication httpApplication, ApplicationContext applicationContext)
            {
                //your code here
            }
    
            public void OnApplicationStarted(UmbracoApplication httpApplication, ApplicationContext applicationContext)
            {
                //your code here
            }
    
    
            public SetDefaultsHandler()
            {
                Document.New += new Document.NewEventHandler(Document_New);
            }
    
            void Document_New(Document sender, umbraco.cms.businesslogic.NewEventArgs e)
            {
        //CODE HERE
        }
    }
    

     

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Jan 09, 2013 @ 12:06
    Stefan Kip
    0

    Nope it isn't, you shouldn't add a constructor.

    Move the "Document.New +=" line to the OnApplicationStarting method.

  • Edwin van Koppen 156 posts 270 karma points
    Jan 10, 2013 @ 10:00
    Edwin van Koppen
    0

    public void OnApplicationStarting(UmbracoApplication httpApplication, ApplicationContext applicationContext) {
                Document.AfterPublish += DocumentEvents.Document_AfterPublish;
                Document.AfterSave += DocumentEvents.Document_AfterSave;
            }

     

Please Sign in or register to post replies

Write your reply to:

Draft