Reputation: 39220
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?
Upvotes: 3
Views: 2922
Reputation: 4911
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.
Upvotes: 8