Custom login background for Optimizely CMS 12

Den här artikeln är inte översatt till svenska och visas därför på engelska istället.

This blog post guides you through customizing the login background image in Optimizely CMS 12 by using a simple middleware.

Uppskattad lästid : 4 minuter

Gå till avsnitt

Key takeaways

  • The default background can be replaced using middleware

Optimizely CMS 12, renowned for its flexibility and ease of customization, allows developers to personalize various aspects of the CMS experience. One such aspect is the login page, which can be the first point of interaction for many users.

A custom login background can reinforce brand identity and provide a more engaging user experience. In this blog post, we'll explore how to change the login background image using a simple code snippet in Optimizely CMS 12.

Understanding the code

Before diving into the implementation, let's break down the code snippet provided:

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    app.UseEndpoints(endpoints =>
        endpoints.MapGet("/Util/images/login/login-background-image.png", context =>
            context.Response.Redirect("/Images/login.jpg", false);
            return Task.CompletedTask;

This snippet is part of the Configure method in the Startup.cs file of your Optimizely CMS 12 project. The Configure method is where you define the HTTP request pipeline, and here's what each part of the code does:

  1. app.UseEndpoints: This sets up the endpoints for request handling in the application.

  2. endpoints.MapGet: Here, we are creating a mapping for a GET request. The URL pattern "/Util/images/login/login-background-image.png" is what we're targeting, which is the default path for the login background image in Optimizely CMS 12.

  3. context.Response.Redirect: This line redirects the request to a new image file, "/Images/login.jpg". You should replace this with the path to your custom image file.

  4. return Task.CompletedTask: This completes the asynchronous operation.

Implementation steps

  1. Prepare your custom image: First, ensure you have your custom background image ready. Ideally, this should be a .jpg or .png file, and you should consider its dimensions and file size to ensure it loads quickly and looks good on various screen sizes.

  2. Add the image to your project: Place your custom image in the directory of your Optimizely CMS 12 project. The image file can be placed anywhere in the project folder structure, just make sure it is publicly accessible.

  3. Update the Startup.cs file: Open the Startup.cs file and locate the Configure method. Insert the provided code snippet into this method. Make sure to update the file path in the context.Response.Redirect line to point to your custom image. 


Customizing the login page background in Optimizely CMS 12 is a straightforward process that can significantly enhance the user experience. By following these simple steps and utilizing the provided code snippet, you can easily inject a bit of personality and branding into your CMS. Remember, such small customizations can make a big difference in how users perceive and interact with your platform.

Feel free to reach out in the comments for any questions or if you'd like to share your experiences with customizing Optimizely CMS 12!