4

I have been trying to have my web app to redirect to a custom 404 page. It works for all urls except if they have a ".aspx" extension

The server is a Windows Server 2008 and here are the following settings I have in my web.config (using google.com as a quick example):

<customErrors defaultRedirect="http://www.google.com" mode="On" redirectMode="ResponseRedirect"></customErrors>

<httpErrors errorMode="Custom">
<clear />
<remove statusCode="500" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/404-Page/" responseMode="ExecuteURL" />
<error statusCode="500" prefixLanguageFilePath="" path="/404-Page/" responseMode="ExecuteURL" />
</httpErrors>

Again the HTTP Errors work for everything but extensions of ".aspx"

Channafow
  • 707
  • 3
  • 8
  • 17

3 Answers3

0

The customErrors element provides information about custom error messages for an ASP.NET application. Try adding a error child element to the customErrors element for the specific HTTP error code you want to trap.

<error statusCode="404" redirect="error404.htm"/>
DaveB
  • 9,470
  • 4
  • 39
  • 66
0

I had a similar problem in IIS6. I ended up handling it in Application_Error in global.asax. To make it work I had to set the 404 custom page to an aspx page that didn't exist (if I set it to an existing aspx page it would get swallowed up by EPiServer's internal error handling...)

Anders Bornholm
  • 1,326
  • 7
  • 18
0

Well to solve this issue, we ended up having to create a module that hijacks any errors and transfers the user to my custom 404 page that is set in the web.config (under customErrors). The module would add an event handler to whenever the application gets an error:

    public void Init(HttpApplication context)
    {
        context.Error += new EventHandler(FileNotFound_Error);
    }

And the function FileNoteFound_Error does the redirection.

Channafow
  • 707
  • 3
  • 8
  • 17