配置文件不是格式良好的 XML #2
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17792419/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Configuration file is not well-formed XML #2
提问by MacGyver
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?
我正在尝试修复 Windows Server 2008 上的 IIS 7 Web 服务器。我不知道是什么导致此配置变坏。关于从哪里开始寻找的任何想法?
Error when clicking on the server node in the object explorer of IIS Manager.
在 IIS 管理器的对象资源管理器中单击服务器节点时出错。
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


采纳答案by MacGyver
Follow this, but do not copy the "schema" folder, nor the "Export" folder from the history to the current folder.
按照此操作,但不要将“schema”文件夹或“Export”文件夹从历史记录复制到当前文件夹。
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!
我能够重现这个问题!!错误地修改 Web.Config(参见下面问题的答案)最终导致了这个问题。因为我做了所有这些事情,所以我必须从服务器备份中恢复以修复所有内容,因为撤消所有内容太难了。坏坏坏微软!
ASP.NET Generic Handler not getting called after .NET 3.5 to .NET 4.0 upgrade
ASP.NET 通用处理程序在 .NET 3.5 到 .NET 4.0 升级后未被调用
This question is related to:
这个问题与:
https://serverfault.com/questions/525443/how-to-uninstall-iis-from-windows-server-2008/525496#525496
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.
经验教训:在 Web 服务器部署之前,在更改 IIS 7 配置或进行 Web.Config 更改之前,将内容复制出此文件夹。
C:\Windows\system32\inetsrv\config\
回答by user3013626
This issue is due to the file 'applicationhost.config' getting corrupted.
此问题是由于文件“applicationhost.config”损坏所致。
The backup of this file is stored at C:\inetpub\history\.
Delete the corrupted file C:\Windows\system32\inetsrv\config\applicationhost.configand restore it from the backup. Then start \ restart IIS.
此文件的备份存储在C:\inetpub\history\. 删除损坏的文件C:\Windows\system32\inetsrv\config\applicationhost.config并从备份中恢复它。然后启动\重新启动IIS。
The problem will be resolved.
问题将得到解决。
回答by Eric Kramer
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.
这只是发生在我帮助管理员的服务器上。我们正在排除故障,但我们最近绝对没有更改 IIS 中的任何会修改配置文件的内容……它只是变空了(0 字节)。现在正在调查最近的补丁是否可能导致它。
回答by live-love
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
尝试连接时出错。是否要重新键入凭据并重试?文件名: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.
解决方案是将 C:\Windows\System32\inetsrv\config 中的 redirection.config 文件中的 enabled 从 true 更改为 false。
<configurationRedirection enabled="false"
More details here: http://blogs.iis.net/wonyoo/shared-configuration-and-password-expiration
更多细节在这里:http: //blogs.iis.net/wonyoo/shared-configuration-and-password-expiration
回答by Shrikant
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.
只需从该位置删除文件 applicationHost.config 并重新加载项目。它会在重新加载项目时自动创建新的 applicationHost.config 文件。
回答by God Inez
In my case it was because some lines of web.config had comments with characters like ?or ?.
就我而言,这是因为 web.config 的某些行有诸如? 或者?.
Converting the file to from ANSI to UTF-8 encoding using Notepad++ solved the problem.
使用 Notepad++ 将文件从 ANSI 转换为 UTF-8 编码解决了这个问题。

