Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

web.config errors fail with responseMode="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 custom error page, but returns a 200 OK status code.

When I change "ExecuteURL" to "File", my server does return a 404, but the custom error page is not displayed. Instead, I get the message "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

How is web.config supposed to read, to return a static file, but also a 404?

Edit: removed <customErrors> questions after learning that that tag is for IIS <= 6.0

like image 903
Trojan Avatar asked Jul 08 '13 18:07

Trojan


1 Answers

I was figthing with exactly same problem pretty long time. Now I found out by accident that the problem is in the slash character.

this is working for me - no beginning slash and use \ instead of /

  <error statusCode="404" path="Static\WebServer\PageNotFound.htm" responseMode="File" /> 
like image 109
Lukas K Avatar answered Sep 28 '22 06:09

Lukas K