2

In windows 7 I'm trying to set up custom error pages. One for 404, one for 500, and one catch all for any other error (client side or server side) that a user may encounter when something times out, or there is a malfunction when asp does its compiling.

404.htm
500.htm
error.htm

Just really simple html pages that say error and nothing technical like the defaults. This post and this post seem to be talking about crafting the error pages in ASP, not just taking an html file and setting it as a custom error page.

In IIS I have gone to the error page selection tool that is not meant for ASP

IIS Error menu

And entering this information into the Edit error pages settings dialogue

Full address I've entered: WebvView\webview_error_pages\error.htm (by selecting after I've hit the elipses button to the side to browse. (I've shortened all of these addresses for this post).

enter image description here

The custom default address works. But when I try to make an error page for 404 like this:

dialogue for 404

404 appears on list

and try to go to a page which doesn't exist, I get this simple error message:

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

Not mine. And not the default that was working before I set up the custom 404.

What am I doing wrong?

Thanks!

EDIT

also, I've just changed some part of the ASP and gotten a runtime error and not my custom error. Is there any way to stop users from seeing these frighteningly technical pages??

EDIT this is the xml code for the other status menus:

    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" />
        <customErrors defaultRedirect="webview_error_pages/error.htm" mode="On">
        </customErrors>
  </system.web>
    <system.webServer>
        <httpErrors errorMode="Custom">
            <remove statusCode="502" subStatusCode="-1" />
            <remove statusCode="501" subStatusCode="-1" />
            <remove statusCode="500" subStatusCode="-1" />
            <remove statusCode="412" subStatusCode="-1" />
            <remove statusCode="406" subStatusCode="-1" />
            <remove statusCode="405" subStatusCode="-1" />
            <remove statusCode="401" subStatusCode="-1" />
            <remove statusCode="403" subStatusCode="-1" />
            <remove statusCode="404" subStatusCode="-1" />
        </httpErrors>
    </system.webServer>

Thanks again!

1 Answer 1

6

Is there a specific reason why you're not doing this in your web.config? This will help if you move your project to a different server, you then won't have to worry about manually configuring IIS. Also, it's a bit easier to configure it in web.config IMO.

In the customErrors node under system.web, make sure you have

        <customErrors mode="On" defaultRedirect="~/Error/" >
           <error statusCode="404" redirect="~/404Redirect/"/>
        </customErrors>

Obviously you can substitute whatever redirect page you'd like.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks! where is the location of the file? is that where the tilde is? Will it work for those compilation errors asp is giving me :/
The tilde character represents the root directory of the application. This will work for compilation errors
Wow, going to the source really worked. For whatever reason having used IIS to turn that feature to "always" on, did not change the xml config file. Thanks for the help! :)
I added the code for the custom error messages. Do you know how I can amend that code to add a 404 page? Thanks.
I added what I consider to be the relevant code to the last edit on the question :D

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.