Reputation: 12523
My website is configured to display a custom HTML-page when an error occurs. This works fine on both IIS and ASP.NET Development Server. However, as soon as I deploy the application to Windows Azure, I get HTTP 500 instead of 404 for non-ASP.NET-URLs.
This is what the relevant web.config-sections look like:
<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. The httpErrors
section doesn't, however. Even though Azure's IIS sends a 500 to the browser, it logs a 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
Locally, I get a HTTP 500.19 with some more detailed information:
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">
Googling lock violation didn't help me too much, as results usually told me about Standalone IIS. There aren't any errors in the Windows event log.
I'd like to display the Error404.html
for any 404 on both Azure and Standalone IIS. Any help would be great.
Upvotes: 2
Views: 2452
Reputation: 28325
Well, the obvious question is: have you made sure your custom error page is actually deployed to your Azure Web Role instance?
Second question: does it work in the Azure emulator?
Update:
The error message indicates that the config section is locked on your target IIs.
Read this Introduction to ApplicationHost.config.
You probably need to unlock the httpErrors section.
Also, take a look at this solution for a similar error.
Upvotes: 4