Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't make httpErrors to work

I've added the following to config file.

<system.webServer>
  ...
  <httpErrors errorMode="Custom"
              existingResponse="Replace" 
              defaultResponseMode="ExecuteURL">
    <clear/>
    <error statusCode="404"
           responseMode="ExecuteURL"
           path="http://google.se" />
  </httpErrors>
</system.webServer>

However, it seems that I still get the default page with yellow background and the stack trace. I've tried commenting out the filter for error handling and adding/removing custom errors in system.web. (I'm trying the approach of httpErrors as suggested in this great article.)

What am I missing? What more can I do to trouble-shoot it?

like image 870
Konrad Viltersten Avatar asked Jul 05 '26 13:07

Konrad Viltersten


1 Answers

You can do it at an ASP.NET level like that :

<system.web>
    ...
    <customErrors mode="On">
        <error statusCode="404" redirect="http://www.google.se"/>
    </customErrors>
</system.web>

If you really want to dot it at IIS level, you can like that :

<system.webServer>
    <httpErrors errorMode="Custom" existingResponse="Replace">
        <remove statusCode="404"/>
        <error statusCode="404" path="http://www.google.fr" responseMode="Redirect"/>
    </httpErrors>
</system.webServer>

When you want to redirect to an absolute URL, you must set the "responseMode" attribute to "Redirect", "ExecuteURL" is for dynamic served content, from MSDN.

like image 74
Fabien ESCOFFIER Avatar answered Jul 08 '26 03:07

Fabien ESCOFFIER



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!