Trials, Tribulations, and Triumphs of CMS 12 – Pt. 1

I have recently moved to a new company, and naturally I am working on new projects and opportunities. The first thing that I ended up working on is a CMS 12/.NET 5 project, which is brand new to me.

This series is specifically to document and share the issues that I have come across while getting my bearings in the new .NET 5/6 + CMS 12 world.

In this post, we will go through the following:

MY FIRST THOUGHTS

When I first got into an (already established/created) solution for the project, I honestly didn’t see too much different until I got into it.

  • Block Controllers became Components
    • This is really not much different other than nomenclature
  • Initialization modules turned into Middleware
    • This is where a lot of my issues happened, since theres a few places to place middleware/logic for the startup
    • Program.cs (services/app), Startup.cs (hostbuilder configuration), etc…
  • Web.config is gone, in terms of actual configuration/transforms
  • Deployments locally and in DXP act different, for instance IIS/Express hosting locally vs Docker hosting using Kestrel in DXP

None of these things were completely unknown, nor hard to grasp the concept of, but it was indeed different from what I was used to.

CONFIGURING FOR UPLOADING LARGER FILE SIZES

Usually in a CMS11 solution, if we needed to upload different file sizes, we would simply use the web.config to configure everything.

In this CMS12 solution, it took a bit of debugging and trial/error to allow uploading a larger singular file, but also uploading multiple larger files.

I started scouring the internet for all of these different ways to configure IIS and Kestrel in many different ways, which ended up not working.

(As a side note, my setup is using IIS [not express] to host my local Opti site)

For my local instance, I did have to include a web.config, just simply to configure IIS.

Is this the best way? I’m honestly not sure!

This is what my web.config for my local IIS environment looks like

<?xml version="1.0" encoding="utf-8"?>
<configuration>
	<system.webServer>
		<handlers>
			<remove name="aspNetCore"/>
			<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified"/>
		</handlers>
		<aspNetCore processPath="dotnet"
							arguments=".\mydll.dll"
							stdoutLogEnabled="false"
							stdoutLogFile=".\logs\stdout"
							hostingModel="inprocess" />
	</system.webServer>
	<system.web>
		<httpRuntime maxRequestLength="2147483647" executionTimeout="3600" />
	</system.web>
	<system.webServer>
		<security>
			<requestFiltering>
				<requestLimits maxAllowedContentLength="2147483647" />
			</requestFiltering>
		</security>
	</system.webServer>
</configuration>

As for the DXP environment, this was a bit more difficult, since it was a constant barrage of small changes and then deploying code. (Even with direct deploy, this takes 5-10 minutes per deploy)

Finally, I found a forum post (Thank you, Chris Sharp) that had a configuration for AppSettings, which would allow for larger file uploads.

This is what the node in AppSettings for DXP looks like

"EPiServer": {
    "CmsUI": {
      "Upload": {
        "FileSizeLimit": 2147483647
      }
    }
  },

Suddenly, in my local environment, and more importantly, in DXP we were able to upload singular and multiple large files, per the client’s requirements.

CONFIGURING IMAGE CROPPING AND FORMATTING USING IMAGESHARP

For SEO and performance, we wanted to allow for resizing of images and serving images as WebP.

The requirements were as such:

  • Allow for width and height
  • Ability to serve images as WebP

The solution was on .NET 5 (CMS 12.4.2) and was using Baaijte.Optimizely.ImageSharp.Web.

The issue was that it simply wouldn’t work, and with my research it was due to a an issue described here:

Now, we had two ways to solve this:

  1. Go backwards down to CMS 12.4.1 and then only the height/width cropping would work
    • We could not go down to CMS 12.4.0 because of database versioning
  2. Go up to the, new and not as-supported yet, .NET 6 using CMS 12.5.0. This would allow height/width cropping to work, as well as serving images as WebP
    • This would allow us to use v2.0.0 of the Baaijte ImageSharp library

With a LOT of testing, we ended up doing the upgrade to .NET 6, with a few compilation warnings, but everything worked.

Conclusion

My first impression of .NET Core is actually pretty decent. Better than I thought it would be, honestly.

That being said, it seems that by bringing CMS 12 out with .NET 5, the turmoil was furthered a little bit by .NET 6 coming out so soon. This meant that all/most of the Optimizely libraries (and 3rd party libraries) would need to be updated to .NET 6.

You can see progress of library update progress here: https://world.optimizely.com/resources/net5/add-ons/

In the next part, once I work more on this project, I will try to talk about my experiences with deployments and GeoLocation.

As always, please let me know if you have any comments/questions/concerns. I am more than happy to help!

Eric Markson
Eric Markson

Technical Architect @ Verndale | Optimizely MVP - Platinum | Optimizely Content Cloud SME - Platinum

Articles: 17

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.