0
votes

Im trying to make a redirect to a custom error page on Access Denied (403) and the iis express its just showing the defult ugly 403 page i made the following changes on my web.config

<httpErrors>
  <remove statusCode="403"/>
  <error statusCode="403" path="ErrorManager/InsufcientPrivilage"/>
</httpErrors>

and

<customErrors mode="On">
  <error statusCode="403" redirect="ErrorManager/InsufcientPrivilage" />
  <error statusCode="404" redirect="ErrorManager/PageNotFound"/>

</customErrors>

the strange thing is that the 404 custom error page is working but the 403 dont

1

1 Answers

0
votes

Did you tried something like this:

<customErrors mode="On">
  <error statusCode="403" redirect="~/ErrorManager/InsufcientPrivilage" />
  <error statusCode="404" redirect="~/ErrorManager/PageNotFound"/>
</customErrors>

<system.webServer> 
    <httpErrors errorMode="Detailed" /> 
</system.webServer>

I suggest you to remove httpErrors sub elements as httpErrors are meant for displaying errors for non .net applications. In your case customErrors element is enough.

Regards, Uros