Solutions to the MaxWebConfigSizeInKB error
No CommentsLast week while assisting a customer with a Sitecore upgrade we ran into an error that I'd never seen before (the customer however had). The error was related to the size of the Web.config file exceeding the max size limit (which is by default set to 250kb).
I would imagine that this is a rather edge case scenario but I wanted to point out a few options you have to combat this error should you run into it. The first option is to increase the max size limit by making the following registry hack. While this is definitely a quick win I would argue that it isn't a recommended practice.
The second, which is what I'd consider a recommended practice, would be to reduce the size of your Web.config by moving configuration to external configuration files using .NET's built-in configSource attribute just like Sitecore does with it's connectionStrings node, as detailed below:
<connectionStrings configSource="App_Config\ConnectionStrings.config" />
By moving configuration out of the Web.config you not only shrink the overall size of the Web.config file but you also make it easier to isolate application configuration. Additionally, if you are developing with Sitecore you make it easier to handle future upgrades as your configuration elements are [mostly] separated from Sitecore.
Another recommended practice here is to use external files that end in .config as IIS will not serve those files if browsed to directly. Some additonal reading on this topic can be found here and here.
Hopefully this helps someone. If you agree or disagree with my approach by all means, let me know in the comments below.
More posts in Development
Getting started with Coveo for Sitecore Free Edition
September 18, 2014
Dynamic Sitecore MVC Placeholders
April 22, 2014
Inherit Sitecore insert options with this simple insert rule
April 20, 2014
Technical details for Dust Collected
April 01, 2014