Copied to clipboard

Flag this post as spam?

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


  • Bogdan 250 posts 426 karma points
    Jun 23, 2014 @ 16:06
    Bogdan
    0

    ApplicationEventHandler not firing in Umbraco v6.2.1

    Hi,

    I'm having trouble registering events with ApplicationEventHandler:

    public class RegisterEvents : ApplicationEventHandler
    {
        public RegisterEvents()
        {
            //this is never hit...
        }
    }
    

    Any ideas what may be causing this?

    Thanks!

  • Arjan Woldring 118 posts 224 karma points
    Jun 23, 2014 @ 16:38
    Arjan Woldring
    1

    Hello,

    This is because ApplicationEventHandler is a base class. So you need to override the methods you want to use. Probably the ApplicationStarted can be a good method to override.

    Here you can find an example which will probably help you out: Events Documentation

    Good luck!

  • Volodymyr 5 posts 26 karma points
    Jun 18, 2015 @ 06:56
    Volodymyr
    0

    Hello Arjan

    Could you please advise how to get code of RegisterEvents class to be executed by Umbraco?

    Should I register the class somehow (e.g. in Global.asax ) ?

    Or should it be installed as part of custom plugin?

    Any help is very appreciated.

  • Volodymyr 5 posts 26 karma points
    Jun 18, 2015 @ 07:19
    Volodymyr
    0

    Arjan, please ignore my question. I've already find out - Umbraco automatically resolves any inherited classes from ApplicationEventHandler. So no special 'registration' needed.

  • Bogdan 250 posts 426 karma points
    Jun 23, 2014 @ 16:54
    Bogdan
    0

    Arjan, thank you for your reply. I have already tried overriding the methods. None of them fire unfortunately. And I think you are wrong, I don't think you have to override a method, unless you need something from the Umbraco context. I also found an example of what I'm trying to do here, but as I said the constructor is never hit.

    Thanks!

  • Arjan Woldring 118 posts 224 karma points
    Jun 24, 2014 @ 09:23
    Arjan Woldring
    0

    You are right it should call your constructor. What are you trying to achieve?

  • Bogdan 250 posts 426 karma points
    Jun 24, 2014 @ 10:10
    Bogdan
    0

    I'm actually implementing Tea Commerce and would like to cancel the sending of the confirmation emails when the order status is different from 'authorized'. And that example is very close to what I need, just that in EmailTemplate_MailSending I set the mailMessage to null in some situations.

    There is something weird with the site, I just can't put my finger on it. For example unless I add in views (that do inherit UmbracoTemplatePage) a 'using' directive for the Umbraco.Web namespace, intellisense tells me extensions like GetPropertyValue don't exist on Model.Content... The view still works without the 'using' though. Umbraco was added to an MVC project created with Visual Studio 2013, and it defaulted to MVC 5, so I had to update some of the System assemblies for it to work, but there were no problems there, and I see no reason for this to cause such problems.

    Regards!

Please Sign in or register to post replies

Write your reply to:

Draft