ApplicationStartup

Using ApplicationStartup in Code

To perform specific operations (e.g. register event handlers, etc) on the application startup, you can use the ApplicationStartup attribute on a class which should implement two static methods OnBeforeInitialize and OnInitialize to execute custom code before and after the application initialization phase.

Sample:

using Composite.Core;
using Composite.Core.Application;

namespace Demo
{
    [ApplicationStartup]
    public class MyAppStartup
    {
        public static void OnBeforeInitialize()
        {
            Log.LogInformation("MyAppStartup", "About to get initialized");
        }

        public static void OnInitialized()
        {
            Log.LogInformation("MyAppStartup", "Already initialized");
        }
    }
}

Download the source

Please also see How to attach events to C1 CMS Data Stores?