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

CMS and OWIN

This topic explains what functionality is depending on OWIN and how to create your own startup class.

[New in 7.14]   

Some features in Optimizely Content Management System (CMS) require OWIN middleware that is set up using the OWIN standard (Open Web Interface of .NET). The OWIN framework contains abstractions to simplify building .NET middleware that need to run on multiple hosts. The Microsoft implementation of OWIN, called Project Katana, provides the underlying set of components to ASP.NET applications, enabling them to be flexible, portable, lightweight, and provide better performance

OWIN is configured by code rather than from configuration files. To support this the framework requires a single start up class that is responsible for configuring all middleware. See for example the ASP.NET documentation for details on having different configuration in production and development.

Examples of middleware using OWIN are SignalR, Web API and Federated Security. Since there is no way to compose requirements required by EPiServer features, the website developer have to configure OWIN in a startup class (if you want to use any of the EPiServer functionality that depends on OWIN).

Functionality depending on OWIN

Add-ons and extensions

Live Monitor (the add-on version) requires SignalR.

Service API

Requires Web API.

Federated Security

Requires OWIN security and the WSFederation middleware. See Federated Security for more information.

Example of startup class

Here is an example of how the startup class can look if you are using Live Monitor and the Service API:

using MyWebApp;
using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof (Startup))]

namespace MyWebApp {
  ///
  /// Sets configuration for Owin functionality hosted in IIS.
  ///
  public class Startup {
    ///
    /// Configures the Owin application.
    ///
    ///The  to configure.
    public void Configuration(IAppBuilder app) {
      app.MapSignalR();
      new EPiServer.ServiceApi.Startup().Configuration(app);
    }
  }
}

OWIN start up and optimizeCompilations

If the project previously did not have an OWIN startup class and optimizeCompilations was enabled, then sometimes the new code is never executed. This might result in various errors since the OWIN functionality is never set up. To work around this, temporarily set optimizeCompilations in web.config to false to clear the cache, start the site and then you can set optimizeCompilations to true again.

Related information

Refer to the references below for more about OWIN, Microsofts OWIN implementation named "Katana" and more about the startup class and ways to detect and configure which class to use.