简体   繁体   中英

custom error pages in IIS for Windows 7

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错误菜单

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).

在此处输入图片说明

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

404对话

清单上出现404

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM