Wednesday, August 8, 2012

How To Fix Corrupted applicationHost.config file in IIS 7

Recently one of my SharePoint WFE’s servers applicationHost.config files became corrupted on the server.  Not sure how it happened or what caused it.  Might have been when I was trying to re-provision the User Profile Service Application.  Anyways IIS7 was erroring out with the error below when I tried to access the websites and application pools.  So all websites and web applications were unavailable.

The Windows Process Activation Service encountered an error trying to read configuration data from file ‘\\?\C:\Windows\system32\inetsrv\config\applicationHost.config’, line number ’1′. The error message is: ‘Configuration file is not well-formed XML’

When browsing to: C:\Windows\system32\inetsrv\config\applicationHost.config I noticed that the applicationHost.config files size was 0kb.  What?!  After opening up the file I noticed it was wiped clean.  Something went terribly wrong.  Luckily IIS7 automatically keeps the history of the applicationHost.config file every time there is a change in IIS7.

To access the history of the applicationHost.config file.

1.  Browse to C:\inetpub\history directory
2.  Inside this directory you will find the history of all the applicationHost.config file.
3.  Pick a applicationHost.config file that you know is not corrupted.  I usually pick one a few hours back to be safe.
4.  Copy the applicationHost.config file and paste it into the C:\Windows\system32\inetsrv\config directory, replacing the corrupted file.
5.  Now attempt to access IIS7 again.  This time IIS7 should open, and you should be able to access all your sites and web apps.

No comments:

Post a Comment