0

I have setup a custom 404 page and it works fine for all extension except aspx. They go to the servers generic 404 page.

Here is my code...

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

If I add existingResponse="Replace" to the opening httpErrors tag, the custom 404 page will display but it gets placed underneath the generic 404 output.

Id there a way to get rid of the generic 404 output being displayed above my custom 404 output on these aspx pages?

1 Answers1

0

Have you tried also adding the customErrors element inside of system.web too?

<system.web>
    <customErrors mode="On" redirectMode="ResponseRewrite">
        <error statusCode="404" redirect="/errors/404.aspx"/>
    </customErrors>
</system.web>

There is some discussion about the differences between customErrors and httpErrors here on SO.

johna
  • 10,540
  • 14
  • 47
  • 72
  • I tried that, and that is giving me a 500 error instead. I attempted that in addition with my code and without – jayjayhightower Feb 26 '18 at 03:55
  • 500 error means you may have duplicate sections. if you already have `system.web` you need to insert just the `customErrors` inside of the existing section. Or if you already have `customErrors` you need to replace with these lines. – johna Feb 26 '18 at 07:35
  • I did exactly that. I just placed your customErrors code within my system.web section. I replaced my original customErrors with yours. – jayjayhightower Feb 26 '18 at 08:00
  • Maybe try removing parts until the error goes away to see what is causing it. eg. remove the error row first, then redirect mode, etc. What .NET version are you targeting? – johna Feb 26 '18 at 08:23