Sitecore 8 Upgrades: ‘Cannot read configuration file because it exceeds the maximum file size’

Sitecore 122A warning to others upgrading to Sitecore 8: you may run out of Web.config space!

Recently, I’ve been spending my time working on upgrading a site to Sitecore 8 and I encountered the dreaded 250KB limitation for the Web.config file. For security reasons, IIS will throw the “Cannot read configuration file because it exceeds the maximum file size” error if a single .config file exceeds 250KB.

What is different about Sitecore 8?

This problem isn’t new to Sitecore 8. Any version of Sitecore could potentially go beyond the 250KB limit for the configuration file. However, Sitecore 8 has grown the default Web.config to 241KB. That gives you only 9KB of room in this latest version, which makes it much more probable that you will encounter this error during an upgrade to Sitecore 8.

Sitecore 6.x Web.config came in at around 210KB, and version 7.x grew to around 225KB. When we do upgrades to Sitecore 8, previously working sites can now easily go over the 250KB limit if developers are relying on using the extra space available in previous releases of Sitecore.

In my scenario, the Web.config customizations included rewrite rules in the Web.config which pushed the total file size over the 250KB limit once upgraded to Sitecore 8. At this point, the entire site starts throwing the size limit error.

How to fix the error

While researching what caused the error, the following blog post was very helpful and provided two options for resolution:

https://himadritechblog.wordpress.com/2014/09/27/how-to-fix-cannot-read-configuration-file-because-it-exceeds-the-maximum-file-size/

“Option 2” suggests to move the customized configurations into separate files and include them using the configSource attribute into the Web.config. As long as each individual file is under 250KB, you are okay.

Looking ahead to future upgrades

I think it would be great if all the Sitecore sections could also be split out into smaller files, such as App_Config\Sitecore.config. This is already done for things like Commands and MimeTypes, so it seems like a logical extension. It would also make upgrading easier as the ‘core’ Sitecore application configurations would be in other files and not in the often-changed Web.config file.

Advertisements

2 thoughts on “Sitecore 8 Upgrades: ‘Cannot read configuration file because it exceeds the maximum file size’”

  1. The following Powershell script will resolve this issue if you can’t get the web.config down in size:

    # Increase Maximum Web.config File Size To 512KB
    New-Item HKLM:\SOFTWARE\Microsoft\InetStp\Configuration -ErrorAction SilentlyContinue;
    New-ItemProperty HKLM:\SOFTWARE\Microsoft\InetStp\Configuration\ -Name MaxWebConfigFileSizeInKB -Value 512 -PropertyType “Dword”;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s