This is more of a quick how article than a blog article. However, I think it is useful. We often deal with a big web.config file in Sitecore application. I have seen the following error in some Sitecore applications due to big config file.
This happens when the size of the web.config file exceeds 250 KB. Microsoft added this file size restriction to prevent attacker from uploading large config file to the server and start a possible Denial of Service (DOS) attack.
There are two ways to fix this issue (my choice is Option 2).
Microsoft provided a Registry key for changing this size limit. You can change the following registry key to increase the size.
If you are using 64 bit OS you might have to set the registry key in the following location.
You may find (most probably) that the key doesn’t exist. you have to create one. After creating the key you need to reset IIS before you can see the effect of the new value.
The config file size limit is for per file. The second option is to break the web.config file into more than one config file and use the reference to the second config file from the main file. For example, I can take everything included inside the <Sitecore></Sitecore> element and create a file called sitecore.config and then make reference to the this file from the web.config like below.
<sitecore configSource=”App_Config\sitecore.config” />
App_Config is the folder where I placed the sitecore.config.
I like this solution better than the Option 1 because, because changing registry key applies for all the websites. Where as, this option is only for the website for which I am making the changes. It is more secure too, as I don’t have to mess up with the size limit imposed by Microsoft. Only problem with this option is when the sitecore.config size is bigger than 250KB. In that case we can choose Option 1 or combination of Option 1 & 2.