Copied to clipboard

Flag this post as spam?

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


  • Martin 8 posts 39 karma points
    Nov 26, 2014 @ 15:11
    Martin
    0

    ApplicationStarted never runs

    Hi guys. I have added the following class to the app_code in order to assign a role to new members after they are created. It works great on my local system, but the ApplicationStarted never runs when the code is executed on my Unoeuro hosted site. The log entries aren't added to the log file, which is why I believe ApplicationStarted does not run at all (in other parts of the code, log entries are added just fine).

    Any ideas as to what can be wrong?

    Btw. to make sure the application has restarted, I "touched" the web.config file.

    Code below:

    
    namespace Umbraco.Extensions.EventHandlers
    {
        public class RegisterEvents : ApplicationEventHandler
        {
            protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                Umbraco.Core.Services.MemberService.Created += MemberService_Created;
                Umbraco.Core.Logging.LogHelper.Info(this.GetType(), "MemberService_Created eventhandler added");
            }
    
            void MemberService_Created(Umbraco.Core.Services.IMemberService sender, Umbraco.Core.Events.NewEventArgs e)
            {
                Umbraco.Core.Logging.LogHelper.Info(this.GetType(), "AssignRole started");
                sender.AssignRole(e.Entity.Id, "ExternalUser");
                Umbraco.Core.Logging.LogHelper.Info(this.GetType(), "AssignRole complete");
            }
        }
    }
    
    
  • Martin 8 posts 39 karma points
    Nov 26, 2014 @ 15:36
    Martin
    0

    An update after I fiddled around with it some more: I changed the Build Action in VS2010 on the .cs file of the above mentioned class to "compile" from "content" and now it does actually run the ApplicationStarted on my Unoeuro site. However on my local system it now runs twice! Any ideas?

Please Sign in or register to post replies

Write your reply to:

Draft