IIS8.5 > Sites > mysite > Error Pages > 404

  • Select "Insert content from static file into the error response".

  • Uncheck "Try to return the error file in the client language".

  • Enter path to "notfound.html", I've verifieed it is there.

When I visit a page I know isn't there I get:

The page cannot be displayed because an internal server error has occurred.

Why aren't I getting my custom 404 file?

I don't think it's a permission thing, I've tried moving "notfound.html" to several places, one of which is the actual site wwwroot folder which serves the rest of the site.

  • Guess this will never be answered. It's just a complete mystery and what can you do when the error handler gives an error! – Marcus Mar 20 '14 at 1:19
  • LOL, I just found the solution myself and was just about to post about it. I will enter my own solution but will accept yours as the answer since you were first. Funny how it can go 5 hours of nothing and just when you think nobody will reply then BAM, answered. Thanks mate. – Marcus Mar 20 '14 at 1:51
  • Ok thanks, you are welcome. 5 hours of delay maybe because we are not on the same timezone ;) – krisFR Mar 20 '14 at 1:54
  • Five hours of time, no matter timezones. =) Somone is always awake in the Internet. Btw I tried to answer the question but I get this shit: "Users with less than 10 reputation can't answer their own question for 8 hours after asking. You can answer 3/20/2014 4:30:32 AM. Until then please use comments, or edit your question instead." And I got the message AFTER I wrote my 1266 character long answer. This is retarded serverfault, don't slap new users in the face like this. Don't restrict us, it's bullshit. Will return later to post answer since its written but it pisses me off to have to. – Marcus Mar 20 '14 at 2:01
  • Timezone was a joke :) don't be so nervous, these are the website rules...gain some more reputation and you will be less limited. BTW you got it working, this is what matters, no ? cheers – krisFR Mar 20 '14 at 2:07

This error is generated because an absolute path is detected in web.config.

Absolute physical path (like C:\path\to\notfound.html) is not allowed in system.webServer/httpErrors section in web.config file.

Now you have 2 solutions :

1. Allow physical path in ApplicationHost.config file

By default this file is located in %SystemRoot%\system32\inetsrv\config

Locate this file and Edit it

Search for section <httpErrors ..... >

Then add directive allowAbsolutePathsWhenDelegated="true", like the following :

<httpErrors lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath" allowAbsolutePathsWhenDelegated="true">

Save the file, should work !

2. Use relative path

Relative path means that you will have to store your custom error pages in the root folder of the given Web Site.

Then, go to IIS > Sites > mysite > Error Pages > 404

And setup your custom error page like this :

enter image description here

Click OK, should work !


However, note that :

  • Solution 1 sends a 404 Not Found response
  • Solution 2 sends a 200 OK response
  • Thanks again. I'll post my own solution tomorrow (if I remember). I have to avoid to execute a URL on the site because that does not send an actual 404 response to the server, it will be a 200 response. At least that is how it was on IIS6 which I'm migrating from. That's the reason why I need to use a static file as error response, because it gives an actual error response to the browser. That's another thing Microsoft should make more clear, or better yet: Let us choose if the response should be 404 or 200. – Marcus Mar 20 '14 at 2:04
  • @Marcus The first solution sends a 404, but you are right, the second one sends 200. I've updated my answer accordingly. My advice is to choose the 1st solution – krisFR Mar 20 '14 at 2:26
  • About that 200: connect.microsoft.com/VisualStudio/feedback/details/507171 – Bertvan May 19 '14 at 13:48
  • Wow, thanks, adding allowAbsolutePathsWhenDelegated="true" to my applicationConfig file fixed it. Microsoft sure went out of their way to make that difficult! – Flea May 1 '15 at 20:28
  • @krisFR: In case you don't notice the flag response: Editing 10 times will also autoconvert into community wiki, and at that point, user name changes will not be reflected to the post anymore, as it is then owned by the community♦ user. – Sven May 2 '15 at 18:46

I snooped around and found that there is a thing called "allowAbsolutePathsWhenDelegated" which is set to "false" by default.

IIS8.5 > Sites > mysite > Management > Configuration Editor > system.webServer/httpErrors

However the value is locked and can't be edited there. So I clicked the root in the tree and could edit it there.

IIS8.5 > Management > Configuration Editor > system.webServer/httpErrors

Note that the root is not actually named "IIS8.5", it's named after your computer name.

So after allowAbsolutePathsWhenDelegated was set to true everything worked fine. A different solution would have been to put the static file inside my site's wwwroot folder and just enter the name of it as the 404 error page (though in my case it's better with a absolute path instead of a relative one).

What bugs me is that there is no mention anywhere on the "Error Pages" screen about this default restriction. It doesn't say anything about the path having to be relative to your site root and since the default is NOT relative (it's in the inetpub folder) you assume an absolute path would work fine.

Hopefully Microsoft will fix this interface issue in a later version. Just be more clear about any restrictions in the input fields, please.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.