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

Configure CMS

Describes how to configure and select options in Optimizely Content Management System (CMS) through code, configuration files, or environment variables.

Options

Configurable Optimizely Content Management System (CMS) settings are exposed as option classes. An option class is a POCO C# class that is singleton registered in the DI container in the .NET Core application. See also Options pattern in ASP.NET Core.

Configure options programmatically

Options classes are registered in the service container and can therefore be injected into any service that requires this information. This also means you can modify option values during the configuration phase of the application initialization. One common way to configure an option programmatically is to use the extension method Configure on IServiceCollection as shown below. Another alternative is to register an instance of IConfigureOptions in the IOC container.

public void ConfigureServices(IServiceCollection services) {
  services.Configure<DataAccessOptions>(o => o.UpdateDatabaseSchema = true);
}

You can find more detailed information on individual options classes under the relevant options section.

Configuration files

A common way is to have configuration values in an appSettings.json file and then bind the values from the configuration file to option classes. You can have a custom configuration file format and bind the values to options as described in Bind hierarchical configuration.

By following the pattern where the first element is "episerver" and then the "product" part is specified, followed by the name of the option and the values for the option, you can get binding to options automatically. Below is an example where SchedulerOptions in configuration section Cms is configured:

{
  "EPiServer": {
    "CMS": {
      "Scheduler": {
        "Enabled": "false"
      }
    }
  }
}

For the option class, it is optional to have the class suffix "Options" as above where SchedulerOptions is specified as "Scheduler".

You also may find the following configuration files in a CMS installation:

  • module.config – A configuration file installed with the CMS sample templates, showing how to deploy new modules to your solution.

Environment variables

Another alternative to configure options is to apply settings as environment variables. To get the automatic binding of environment variables to options, use the same convention as in configuration files such as appsettings.json, but with '__' as a separator. Below is an environment variable that configures SchedulerOptions in configuration section Cms.

EPISERVER__CMS__SCHEDULER__ENABLED

Option types

Related topics