Adding custom error pages to a website

I have a website that makes use of a web.config. I tried adding in the following code:

<customErrors mode="On" defaultRedirect="error.htm">
            <error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>

But it doesn't seem to work. Errors still show up. Could I be putting it in the wrong place?

Sample:

<authentication mode="Forms">
      <!-- Assign login url to LOGINSTATUS control -->
            <!-- log user out after 15 minutes of inactivity -->
            <forms loginUrl="~/Tilton/Login/Login.aspx" timeout="15"/>
        </authentication>
    <customErrors mode="On" defaultRedirect="error.htm">
      <error statusCode="404" redirect="FileNotFound.htm" />
    </customErrors>

Answers


The ASP.NET error handler only works for resources that would have been handled by the ASP.NET engine should they exist. Example, your handler should work for nonexist.aspx, but won't work for foo.bar because .bar is not mapped to ASP.NET. Is this your problem?


You could look at setting a custom 404 error page within IIS itself. In IIS 7 there's a 'error pages' configuration section for each website.


Need Your Help

Java initial values and array access basic understanding - unusual output

java arrays queue

I was writing a class to practice my data structures (Queue specifically) and I came across something that was quite odd. I initialize a variable (int) to ZERO on the class and later try to use that

Qt: Creating a QDoubleSlider

c++ qt user-interface signals-slots qslider

I want to connect a QDoubleSpinBox with a QSlider like this: