Configuration file related errors in a shared IIS environment
Published Feb 11 2019 07:12 AM 15.4K Views
Microsoft

IIS supports sharing the configuration across multiple web servers. In some cases, you may come across “Configuration file is not well-formed XML” or “Cannot read configuration file” errors in Event Viewer.

 

These error messages indicate that IIS shared config environment is having difficulties syncing the data. This may stop the application pool which means an outage for your application.

 

Check both System and Application containers in Event Viewer to have more details about issue:

5172: The Windows Process Activation Service encountered an error trying to read configuration data from file applicationHost.config line number 0. The error message is: ‘Cannot read configuration file’. The data field contains the error number.

2307: The worker process for application pool abc.com encountered an error ‘Configuration file is not well-formed XML’ trying to read configuration data from file abc.config, line number 3. The data field contains the error code.

bb1.jpg

“Cannot read configuration file”

bb2.jpg

“Configuration file is not well-formed XML”

 

Solution

As this article mentions, DFS deletes the current configuration file and creates every time there is a change in the IIS shared environment. During this process, a member server may retrieve an incomplete config file.

 

Solution 1

The fastest solution is that changing the value of the ConfigPollMilliSeconds parameter to 600000 so that IIS doesn’t rely on file system change notifications. It automatically checks the last modified date of the configuration file every 600000 milliseconds (10 minutes) with this setting. More details: Microsoft Support

The registry key: HKLM\System\CurrentControlSet\Services\W3SVC\Parameters\ConfigPollMilliSeconds (REG_DWORD). Restart the server after changing the value of this registry key.

 

bb3.jpg

 

Solution 2

You can try using Offline Files for the IIS shared folder. If it is production environment, please implement this change after business hours and monitor the system. The changes should be synced and websites are served without any issues.

  1. In Control Panel, open “Offline Files
  2. Click “Enable Offline Files
  3. Run the following command in Command Prompt to set the cache Read Only 
    REG ADD "HKLM\System\CurrentControlSet\Services\CSC\Parameters" /v ReadOnlyCache /t REG_DWORD /d 1 /f
  4. Restart the web server
  5. Go to the file share folder. Right click and select “Always Available Offline
  6. Go to “Control Panel > Offline Files”. Select “Schedule
  7. Schedule offline file sync
Version history
Last update:
‎Mar 18 2019 07:15 AM
Updated by: