web.config doesn't catch all 404's

In my web.config I have:

    <customErrors mode="On" defaultRedirect="~/Error.aspx" redirectMode="ResponseRewrite">
        <error statusCode="500" redirect="~/Error.aspx" />
        <error statusCode="404" redirect="~/404.aspx" />

Yet with these URL's, only the 2nd one with file extension defined works, the other one returns the blue screen 404 "Server Error in Application".

Any ideas? I'm on 4, IIS 7.5.


If you want this to work, you need to configure IIS to pass all requests to the .NET engine. Your first example is not obviously asking for a .NET page, so it is not routed to the .NET engine.

What version of IIS and .NET are you using? This may help.

ASP.Net only gets invoked for file extensions registered to it in IIS. So when you go to invalidpath IIS checks for a file matching that name, then a folder. If neither exists it invokes the 404 page designated in IIS.

Depending on your version of IIS you have a couple of different options. In IIS6 you have to manually set the 404 page from within the IIS manager. In IIS7 and greater you can use the web.config and changes the system.webServer section:

I Have 2 configuration in the same web.config

    <customErrors mode="On" defaultRedirect="/error.aspx" redirectMode="ResponseRedirect">

you could use too customErrors mode="RemoteOnly"


      <httpErrors errorMode="Custom">
          <remove statusCode="401" subStatusCode="-1" />
          <remove statusCode="403" subStatusCode="-1" />
          <remove statusCode="404" subStatusCode="-1" />
          <remove statusCode="500" subStatusCode="-1" />
          <error statusCode="401" path="/401.aspx" responseMode="ExecuteURL" />
          <error statusCode="403" path="/403.aspx" responseMode="ExecuteURL" />
          <error statusCode="404" path="/404.aspx" responseMode="ExecuteURL" />
          <error statusCode="500" path="/500.aspx" responseMode="ExecuteURL" />

Take a look at path="/404.aspx" is different to path="~/404.aspx" or path="404.aspx"

Also, I would recommend using plain html pages for error pages if possible as they are much more reliable. For example, if the .net session store is unavailable (e.g. session database down) then the error page will try and redirect to the error page an infinitum! Html pages are less reliant on the .net subsystem so more likely to work when things start to fail.

Need Your Help

What keypress will take me to tty13?

console tty

Trying out Ubuntu Intrepid, I have discovered that RightAlt+F1 doesn't take me to tty13.

Installing 7BEE(java build tool)

java compilation

Can someone please help me with 7BEE installation?