我的网站配置为在发生错误时显示自定义 HTML 页面。这在 IIS 和 ASP.NET 开发服务器上都可以正常工作。但是,一旦我将应用程序部署到 Windows Azure,我就会得到 HTTP 500 而不是非 ASP.NET-URL 的 404。
这是相关的 web.config-sections 的样子:
<httpErrors errorMode="Custom">
<clear />
<error statusCode="404" path="/Public/Error404.html" responseMode="ExecuteURL" />
</httpErrors>
<customErrors defaultRedirect="/Public/Error.html" mode="On">
<error redirect="/Public/Error404.html" statusCode="404" />
</customErrors>
该customErrors
部分(适用于以 .aspx 结尾的 URL)可以正常工作。但是,该httpErrors
部分没有。即使 Azure 的 IIS 向浏览器发送 500,它也会记录 404:
2012-02-10 13:30:07 W3SVC1273337584 RD00155D3A1439 10.61.70.39 GET /asdfdsaafds - 80 - 65.52.128.172 HTTP/1.1 Mozilla/4.0+(兼容;+MSIE+8.0;+Windows+NT+6.1;+WOW64;三叉戟/4.0;+SLCC2;+.NET+CLR+2.0.50727;+.NET+CLR+3.5.30729;+.NET+CLR+3.0.30729;+.NET4.0C;+.NET4.0E) - - 940af2dbd9df4924b87a13878752aee3.cloudapp.net 404 0 2 222 457 218
在本地,我得到一个 HTTP 500.19,其中包含一些更详细的信息:
无法访问请求的页面,因为该页面的相关配置数据无效。
配置错误锁定冲突
238:
<httpErrors errorMode="Custom" defaultPath="/Public/Error.html" existingResponse="Replace" defaultResponseMode="ExecuteURL">
谷歌搜索锁冲突对我没有太大帮助,因为结果通常告诉我有关独立 IIS 的信息。Windows 事件日志中没有任何错误。
我想Error404.html
在 Azure 和独立 IIS 上显示任何 404。任何帮助都会很棒。