当IIS7发生错误时出现500.19错误

20

背景:Windows 7,IIS7。我正在开发一个应用程序,该应用程序通过本地 IIS 服务器查看,而不是内置的调试 Web 服务器。因此,我的应用程序 URL 是 http://localhost/foo/bar.aspx。在我的 web.config 中没有任何<customErrors>部分,并且我也没有更改过 IIS 的任何设置。

如果出现任何错误,我总是会收到以下错误屏幕:

HTTP 错误 500.19 - 内部服务器错误
在 web.config 文件的system.webServer/httpErrors部分中,绝对物理路径 "C:\inetpub\custerr" 不允许使用。请改用相对路径。

这是我的applicationhost.config内容:

<httpErrors errorMode="Custom" lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath">
  <error statusCode="401" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="401.htm" />
  <error statusCode="403" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="403.htm" />
  <error statusCode="404" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="404.htm" />
  <error statusCode="405" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="405.htm" />
  <error statusCode="406" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="406.htm" />
  <error statusCode="412" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="412.htm" />
  <error statusCode="500" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="500.htm" />
  <error statusCode="501" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="501.htm" />
  <error statusCode="502" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="502.htm" />
</httpErrors>

我该如何消除这个配置错误,以便能够查看详细错误信息?

5个回答

43

最近几天我一直在处理这个问题,现在已经找到解决办法了。问题出在Web.Config文件中指定了一个错误页面的绝对路径。但是这个Web.Config文件可能不是你正在测试的应用程序的文件,对于我来说,是网站的Web.Config文件。

  1. 如果你找到了有问题的Web.Config文件,你可以删除其中的绝对路径,这样问题就会被解决。

  2. 一个更简单的解决办法是修改你的ApplicationHost.Config文件,将allowAbsolutePathsWhenDelegated属性设置为true

    <httpErrors allowAbsolutePathsWhenDelegated="true" errorMode="Custom" 
                lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath">
    

1
你的贡献无法用点赞来表达。我在网站根目录下有一个web.config文件,将其全部删除了。太棒了!!!!!! - Joel
https://dev59.com/O2855IYBdhLWcg3waDiR - Jared314
我有iis7.5和vs2013,但在配置文件中不允许使用此属性。尝试推送后,错误仍然出现。 - DanielV
1
实际上这个答案解决了我的问题! - DanielV

2

当我在域控制器上安装Active Directory证书服务时,遇到了相同的问题。它们都使用443端口。我将证书服务的端口更改为服务器IP地址,并将交换服务器保持未分配状态。这解决了我的问题。


1

我在IIS 8.5遇到了同样的问题。解决方法是删除web.config文件(位于网站根目录中)中引用自定义错误页面的任何条目。这些条目是系统在我尝试更改自定义页面时创建的。


1

帮助我解决这个错误的方法是将allowAbsolutePathsWhenDelegated设置为true。

进入,将allowAbsolutePathsWhenDelegated设置为true。为了保险起见,重置IIS


0
对我来说,解决方案是设置自定义账户:选择应用程序-->右侧基本设置-->连接为-->提供用户名和密码,然后在inetpub>wwwroot>文件夹名称的项目文件夹上为此用户分配完全权限。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接