简体   繁体   English

httpErrors配置部分在Windows Azure中不起作用

[英]httpErrors config section not working in Windows Azure

My website is configured to display a custom HTML-page when an error occurs. 我的网站配置为在发生错误时显示自定义HTML页面。 This works fine on both IIS and ASP.NET Development Server. 在IIS和ASP.NET开发服务器上都可以正常工作。 However, as soon as I deploy the application to Windows Azure, I get HTTP 500 instead of 404 for non-ASP.NET-URLs. 但是,将应用程序部署到Windows Azure后,对于非ASP.NET-URL,我将获得HTTP 500而不是404。

This is what the relevant web.config-sections look like: 这是相关的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>

The customErrors section (applied to URLs ending on .aspx) works properly. customErrors部分(适用于以.aspx结尾的URL)可以正常工作。 The httpErrors section doesn't, however. 但是, httpErrors部分没有。 Even though Azure's IIS sends a 500 to the browser, it logs a 404: 即使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+(compatible;+MSIE+8.0;+Windows+NT+6.1;+WOW64;+Trident/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 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 +(compatible; + MSIE + 8.0; + Windows + NT + 6.1; + WOW64; + Trident / 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 222457218

Locally, I get a HTTP 500.19 with some more detailed information: 在本地,我得到一个HTTP 500.19,其中包含一些更详细的信息:

The requested page cannot be accessed because the related configuration data for the page is invalid. 无法访问请求的页面,因为该页面的相关配置数据无效。

Config Error Lock violation 违反配置错误锁定

238: <httpErrors errorMode="Custom" defaultPath="/Public/Error.html" existingResponse="Replace" defaultResponseMode="ExecuteURL"> 238: <httpErrors errorMode="Custom" defaultPath="/Public/Error.html" existingResponse="Replace" defaultResponseMode="ExecuteURL">

Googling lock violation didn't help me too much, as results usually told me about Standalone IIS. 谷歌搜索违反锁并没有太大帮助,因为结果通常告诉我有关独立IIS的信息。 There aren't any errors in the Windows event log. Windows事件日志中没有任何错误。

I'd like to display the Error404.html for any 404 on both Azure and Standalone IIS. 我想在Azure和独立IIS上显示任何404的Error404.html Any help would be great. 任何帮助都会很棒。

Well, the obvious question is: have you made sure your custom error page is actually deployed to your Azure Web Role instance? 好吧,显而易见的问题是:您是否已将自定义错误页面确实部署到Azure Web Role实例?

Second question: does it work in the Azure emulator? 第二个问题:它可以在Azure模拟器中工作吗?

Update: 更新:
The error message indicates that the config section is locked on your target IIs. 错误消息表明config部分已锁定在目标II上。
Read this Introduction to ApplicationHost.config . 阅读此ApplicationHost.config简介 You probably need to unlock the httpErrors section. 您可能需要解锁httpErrors部分。

Also, take a look at this solution for a similar error. 另外,请查看此解决方案是否存在类似错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM