Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi ,
I tried to redirect error pages to custom pages ,but in network tab in browser its showing as 302 instead 404 can please suggest how can i overcome this issue

What I have tried:

<customerrors mode="On">
<error redirect="~/Error/Error401" statuscode="401">
<error redirect="~/Error/Error403" statuscode="403">
<error redirect="~/Error/Error404" statuscode="404">
<error redirect="~/Error/Error500" statuscode="500">
Posted
Updated 28-Jan-20 8:04am
v2

By default, ASP.NET will issue a 302 redirect to the error handler. You can change that by setting the redirectMode to ResponseRewrite:
XML
<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.
 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900