web.config size limit – Overcome IIS 500.19 error

Hi everyone, today I’d like to share an experience I had on a production server. At the beggning I though the problem was related with a SharePoint server, indeed it was related with SharePoint, but in this case to be more precise, with IIS.

We were updating some solutions in SharePoint that adds configuration to the web.config file of SharePoint, but when we tried to refresh the site homepage to test the configuration made, we got a 500 error
In this case, the web.config file size was exceeding the limits. Indeed, by design a web.config file should not exceed 250kb. From there, two solutions could be chosen to solve this issue, ang get access back to our website.

So to solve this problem, the solution is to modify the size configured by design for a web.config file in the registry. To do so, open your registry by typing regedit in windows start menu, and find the following key:
Create a new key named “Configuration”, and a DWORD value named “MaxWebConfigFileSizeInKB”. Change the value of this DWORD to match your requirement. For example, I set 2048 in decimal, which translates to 0x00000800 ib hexadecimal.

To refresh this changes, is it necessary to open an administrator CMD and type iisreset, once the web is refreshed you will be able to access again.

Alternative solution

If you don’t want to add registry entries in your server, there is another solution that allows to split the web.config file in several files.

In this case, you will have a main web.config file in which you’ll reference sub config files by adding a configSource attribute onto the sections you would like to split into other files.

To illustrate this, if you’d like to split the section “appsettings” in another file, you would change the appSettings section in your web.config file to :

  appSettings configSource="appsettings.config"

So, you will need to add all your appsettings entries like they were in the original web.config file, for example :

add key="aspnet:RestrictXmlControls" value="true"
add key="FeedCacheTime" value="300"
add key="FeedPageUrl" value="/_layouts/15/feed.aspx?"
add key="FeedXsl1" value="/Style Library/Xsl Style Sheets/Rss.xsl"
add key="aspnet:AllowAnonymousImpersonation" value="true"

So, after doing this, you’ll have two files (web.config and appsettings.config) in the inetpub folder, so remember that you will need to modify each on of the files, and in case you need to do some configuration changes to do an iisreset to deploy the changes to the webapp.

Hope it helps someone!


2 thoughts on “web.config size limit – Overcome IIS 500.19 error

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 )

Facebook photo

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

Connecting to %s