HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Create an initialization module

Describes how to create an initialization module to work with the initialization system in the Optimizely platform.

When you create your initialization module, add a reference to EPiServer.Framework.dll. The following initialization code example sets up a property with a default implementation in Initialize, then undoes the process in Uninitialize:

[InitializableModule]
public class SampleInitialization: IInitializableModule {
  public void Initialize(InitializationEngine context) {}
  public void Uninitialize(InitializationEngine context) {}
}
  • The initialization engine ensures that your code executes in a single-threaded manner.

    You do not need to lock regions when you deal with a shared state. This guarantee is only made for Initialize and Uninitialize when you execute through the initialization system. You may have to deal with multi-threading issues if you have custom code that makes calls directly into your initialization module.

  • The initialization system tracks the initialization state of your module.

  • Implement Uninitialize – Anything you do with Initialize must be undone with Uninitialize in the reverse order of Initialize. This is important if you write integration tests that reset applications between test runs.

  • If you are using the CMS API, add a module dependency to CMS using [ModuleDependency(typeof(EPiServer.Web.InitializationModule))].