The Content Management module is the heart of your content-managed website. Every application in your platform that has anything to do with content management will require this module to be installed. The module consists of separate web and back office packages, that may be installed into the same application, or in separate applications, if you want to separate your back office from your web rendering application.

Only applications that do not have any content management functions, for example, user provisioning scripts, do not require this module to be installed.

Installation

The Content Management module consists of 2 components: the Redakt.ContentManagement.Web package containing the middleware to include in your web project, and the separate Redakt.ContentManagement.BackOffice package containing the back office components to include in your back office project. If you have a single project for both web publication and back office, you include both packages in that project. The Redakt.ContentManagement package containing common classes and services is installed as a dependency of either web or back office packages.

In your web project, install the Content Management web package with the NuGet package manager or the Package Manager Console.

PM> Install-Package Redakt.ContentManagement.Web

In your back office project, install the Content Management back office package with the NuGet package manager or the Package Manager Console.

PM> Install-Package Redakt.ContentManagement.BackOffice

Service registration

Services for the Content Management module are registered automatically by the default services.AddRedakt() call, so you don't have to register this module explicitly. Alternatively, if you prefer to register modules manually or need to pass configuration options, you can do so by calling services.AddRedakt(false) instead to prevent automatic module registration. In that case, you have to register the module explicitly as follows.

Register Content Management services in the ConfigureServices() method in your project's Startup.cs file by adding an AddContentManagement() call to the Redakt builder instance. The order in which services are added to the Redakt builder is not important. If you have separate web publication and back office projects, you need to register Content Management services in both projects.

public void ConfigureServices(IServiceCollection services)
{
    // ... framework and other services here

    var builder = services.AddRedakt(false);  // Pass false to prevent automatic registration of installed Redakt modules.
    builder.AddContentManagement();  // Optionally pass Action<ContentManagementOptions> parameter.
    // ... other Redakt services
}

Configuration settings

The Content Management module can be configured through the appsettings.json file. Any configuration that is not included in the appsettings.json file will be set to its default values. Additionally, an Action<ContentManagementOptions> configuration delegate may be passed to the AddContentManagement() call. Configuration set through this delegate takes priority and overrides values in the appsettings.json file.

{
    "Redakt": {
        "ContentManagement": {
            "PageRendering": {
                "IgnorePaths": [ "/redakt", "/media" ]
            },
            "Media": {
                "BaseUrl": "/media",
                "ImageCachePath": "App_Data/cache",
                "DefaultQuality": 75,
                "PreferWebP": true,
                "CacheControlMaxAge": 0
            }
        }
    }
}

Page Rendering

Ignore Paths

This is an array of (partial) absolute URLs. Any URL that starts with one of these paths will be ignored by the page rendering middleware. Even though paths will not be handled by the page rendering middleware if there is no published URL for them, adding them to the ignore list will save some middleware processing. Defaults to [ "/redakt", "/media" ] (the default paths for the back office and media middleware).

Media

Base Url

Sets the base URL for media files served by the file middleware. Defaults to "/media". If you are serving media files off a CDN, you can set this to the fully qualified CDN media base URL (f.e. "https://assets.redaktcms.com/media").

Image Cache Path

Sets the local file root path that images are cached to, relative to the website root. Defaults to "App_Data/cache". Set to empty to disable image caching (not recommended).

Default Quality

Sets the quality for compressible image types (f.e. JPEG & WebP) when no explicit quality is specified. Defaults to 75.

Prefer WebP

If set to true, raster images are served in WebP format if both the user agent and the image processor support it. Defaults to true.

Cache Control Max Age

Sets the maximum HTTP cache age for media files in seconds. Defaults to 2592000 (30 days). Different files are always served from different URLs (even if they are a replacement file for the same asset), therefore a long caching period is recommended.

Middleware registration

The Content Management module requires its page rendering middleware to be inserted into the ASP.NET Core request pipeline in your web project (not your back office project if it is a different one). Add the page rendering middleware to the request pipeline in the Configure() method of your project's Startup.cs file. The code snippet below shows the correct order in which to add Redakt middleware when you're also including other Redakt middleware in this project.

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    // ... other pipeline configuration here

    // Other Redakt middleware registration first
    app.UseRedaktIdentityServer();
    app.UseRedaktBackOffice();
    // Redakt page rendering
    app.UseRedaktPageRendering();
}