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

Joe*_*oel 18 iis iis-7 http-error

设置:Windows 7,IIS7.我正在开发一个通过本地IIS服务器查看的应用程序,而不是内置的调试Web服务器.所以我的应用网址是http://localhost/foo/bar.aspx.有没有 <customErrors>在我的web.config部分,我还没有在IIS中更改的设置.

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

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

这是我的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>
Run Code Online (Sandbox Code Playgroud)

如何摆脱此配置错误,以便查看详细错误?

fir*_*fly 31

我过去几天一直在处理这个问题,并找到了解决方案.Web.Config文件可能指定其中一个错误页面的绝对路径.这可能不是您正在测试的应用程序的Web.Config.对我来说,这是该网站的Web.Config文件.

  1. 如果找到有问题的Web.Config文件,则可以删除绝对路径,并且应该修复问题.

  2. 更简单的解决方案是更改ApplicationHost.Config文件以将allowAbsolutePathsWhenDelegated属性设置为true:

    <httpErrors allowAbsolutePathsWhenDelegated="true" errorMode="Custom" 
                lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath">
    
    Run Code Online (Sandbox Code Playgroud)