After installation of recent updates for SharePoint (SP2016, SP2019, SPSE) users may receive an HTTP 500 error with the following additional details:
“Cannot read configuration file because it exceeds the maximum file size”
The upgrade operation in SharePoint invoked through the configuration wizard (psconfig.exe or psconfigui.exe) after installing a SharePoint fix adds duplicate “<authorizedType …/>” entries to the web.config file which increases the size of the web.config file with every upgrade.
SharePoint configures IIS to have a limit of 900 KB for web.config files. As soon as the web.config file exceeds this size the problem will occur.
The underlying problem that causes the duplication is currently under investigation.
As a workaround affected customers can run the PowerShell script create by my colleague Joe Erickson which removes the duplicate entries from the web.config:
By default the script will only report the duplicates but will not remove them. This allows to quickly verify if the web.config is affected. To remove the duplicates you need to us the “RemoveDuplicates” mode:
Be aware that the script only updates the local web.config. If you have multiple web frontend server you need to run the script on each of them.