29

I'm trying to fix an IIS 7 web server on Windows Server 2008. I don't know what caused this configuration to go bad. Any ideas on where to begin to look?

Error when clicking on the server node in the object explorer of IIS Manager.

There was an error when trying to connect.  Do you want to retype your credentials and try again?

Details:

Filename:

\\?\C:\Windows\system32\inetsrv\config\applicationHost.config
Line number: 1
Error: Configuration file is not well-formed XML

enter image description here

JustBeingHelpful
  • 18,332
  • 38
  • 160
  • 245
  • Have you tried to open this file with a browser? – Joe Taras Jul 22 '13 at 16:15
  • It's 0KB. Seems to have been deleted or replaced with a blank file. – JustBeingHelpful Jul 22 '13 at 16:18
  • likely you don't need to recover anything, you should just look at the applicationHost.config file or the web.config and see which one got somehow corrupted. likely someone updated it manually and made it invalid XML, usually it is easy to tell if you open in an XML editor and easy to fix. You can find backup files in c:\inetpub that likely can recover. Also, make sure you are not getting redirected to Wow64 folder and you are in windows\system32\inetsrv\config – Carlos Aguilar Mares Nov 20 '13 at 16:54
  • 1
    This problem started occurring for me right after a failed Windows Update that caused a BSOD in the middle of updating. Replacing the applicationhost.config file from the history (see solution below) was all it took to get things back in order. – RSW Aug 18 '14 at 23:23
  • IIS returns this error if there's a blank line at the start of web.config. It's amazing that none of these answers are solving the supposed problem of badly formed XML; it's almost as if the IIS error message is complete rubbish.... – Steve Smith Jan 06 '23 at 13:05

8 Answers8

42

This issue is due to the file 'applicationhost.config' getting corrupted.

The backup of this file is stored at C:\inetpub\history\. Delete the corrupted file C:\Windows\system32\inetsrv\config\applicationhost.config and restore it from the backup. Then start \ restart IIS.

The problem will be resolved.

Amicable
  • 3,115
  • 3
  • 49
  • 77
user3013626
  • 429
  • 4
  • 4
5

Follow this, but do not copy the "schema" folder, nor the "Export" folder from the history to the current folder.

http://web.archive.org/web/20130110080607/http://jshidell.com/2012/03/27/fixing-corrupted-applicationhost-config-file-in-iis-7/

More info:

I was able to reproduce this issue!! Modifying the Web.Config incorrectly (see answer to question below) ultimately caused this issue. Because I did all of this stuff, I'm having to restore from a server backup to fix everything since it'll be too difficult to undo everything. Bad Bad Bad Microsoft!

ASP.NET Generic Handler not getting called after .NET 3.5 to .NET 4.0 upgrade

This question is related to:

https://serverfault.com/questions/525443/how-to-uninstall-iis-from-windows-server-2008/525496#525496

Lesson Learned: Before a web server deployment, copy the contents out of this folder before ever changing IIS 7 configuration or making Web.Config changes.

C:\Windows\system32\inetsrv\config\
Community
  • 1
  • 1
JustBeingHelpful
  • 18,332
  • 38
  • 160
  • 245
  • likely you don't need to recover anything, you should just look at the applicationHost.config file or the web.config and see which one got somehow corrupted. likely someone updated it manually and made it invalid XML, usually it is easy to tell if you open in an XML editor and easy to fix. – Carlos Aguilar Mares Nov 20 '13 at 16:53
2

In my case simply delete the (.vs) folder in the project directory the problem is resolved. (.vs) folder automatically create when building or open project in visual studio.

Safyan Yaqoob
  • 444
  • 3
  • 11
1

This just happened to a server I help admin. We're troubleshooting but we definitely did NOT recently change anything in IIS that would modify the config file...it just became empty (0 bytes). Now investigating whether recent patching could've caused it.

Eric Kramer
  • 192
  • 2
  • 7
  • Interesting! Word of caution. If you uninstall IIS 7 on Windows Server, it might not work. I could not get it to uninstall on Windows Server! It does uninstall on Windows 7. So if you attempt that approach, have your server dudes make a snapshot of your virtual machine for the server your fixing, before doing any of the work to fix the issue. Thanks for sharing. +1 Always something that keeps us humble. – JustBeingHelpful Apr 30 '15 at 15:13
1

simply delete the file applicationHost.config from that location and reload the project. it will automatically create new applicationHost.config file while reloading the project.

Shrikant
  • 39
  • 4
0

Had a similar problem that was due to the user password recently changing after having imported configuration.

There was an error when trying to connect. Do you want to retype your credentials and try again? Filename: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG\machine.config

The solution was to change enabled from true to false in the redirection.config file in C:\Windows\System32\inetsrv\config.

<configurationRedirection enabled="false" 

More details here: http://blogs.iis.net/wonyoo/shared-configuration-and-password-expiration

live-love
  • 48,840
  • 22
  • 240
  • 204
0

In my case it was because some lines of web.config had comments with characters like ç or ã.

Converting the file to from ANSI to UTF-8 encoding using Notepad++ solved the problem.

jcs
  • 611
  • 2
  • 9
  • 22
0

Turned out to be an & in string which isnt allowed so had to escape it with &#038;

Abdul Ali
  • 1,905
  • 8
  • 28
  • 50