By default, ASP.NET will issue a
302
redirect to the error handler. You can change that by setting the
redirectMode
to
ResponseRewrite
:
<customErrors mode="On" redirectMode="ResponseRewrite">
<error redirect="~/Error/Error401" statusCode="401" />
<error redirect="~/Error/Error403" statusCode="403" />
<error redirect="~/Error/Error404" statusCode="404" />
<error redirect="~/Error/Error500" statusCode="500" />
</customErrors>
NB: Make sure your error handler sets the appropriate status code on the response, otherwise all errors could return a status of
200
.