Web.config errors fail with answerMode = "File"

According to Microsoft's documentation , for static (i.e. HTML) content, web.config should read responseMode="File" for each error.

Currently my web.config includes

 <httpErrors errorMode="Custom"> <!-- remove statusCodes --> <error statusCode="404" path="/error/404.html" responseMode="ExecuteURL" /> </httpErrors> 

This returns the correct user error page, but returns a 200 OK status code.

When I change "ExecuteURL" to "File", my server returns 404, but the user error page does not appear. Instead, I get the message "The resource you are looking for has been deleted, its name has changed or is temporarily unavailable."

How should web.config read in order to return a static file, but also 404?

Edit: remove <customErrors> issues after examining what this tag is for IIS <= 6.0

+7
source share
1 answer

I have been figthing with the exact same problem for quite some time. Now I accidentally found out that the problem is the slash character.

this works for me - don't start slash and use \ instead of /

  <error statusCode="404" path="Static\WebServer\PageNotFound.htm" responseMode="File" /> 
+19
source share

All Articles