Configuration file is not well-formed XML #2
Asked Answered
C

8

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

Chaschase answered 22/7, 2013 at 16:11 Comment(5)
Have you tried to open this file with a browser?Hysteria
It's 0KB. Seems to have been deleted or replaced with a blank file.Chaschase
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\configSamellasameness
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.Floyd
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....Side
C
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\
Chaschase answered 23/7, 2013 at 3:17 Comment(1)
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.Samellasameness
K
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.

Kirkpatrick answered 20/11, 2013 at 15:4 Comment(0)
C
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\
Chaschase answered 23/7, 2013 at 3:17 Comment(1)
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.Samellasameness
C
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.

Chaunceychaunt answered 17/4, 2021 at 6:43 Comment(0)
T
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.

Tayler answered 30/4, 2015 at 13:40 Comment(1)
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.Chaschase
E
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.

Euxenite answered 20/8, 2018 at 10:39 Comment(0)
P
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

Phenacaine answered 9/3, 2016 at 17:26 Comment(0)
B
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.

Banquet answered 7/10, 2019 at 10:32 Comment(0)
S
0

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

Silverts answered 28/10, 2020 at 19:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.