Wednesday, 14 October 2015

How to handle 403 error in ASP.Net

How to handle 403 error in ASP.Net

Using the following code you can not resolve 403 error.

<customErrors mode="On">
      <error statusCode="400" redirect="error/error_page.aspx?ID=400" />
      <error statusCode="403" redirect="error/error_page.aspx?ID=403" />
      <error statusCode="404" redirect="error/error_page.aspx?ID=404" />
      <error statusCode="500" redirect="error/error_page.aspx?ID=500" />
</customErrors>

To resolve 403 error use the following code.

 <httpErrors errorMode="Custom">
      <error statusCode="403" subStatusCode="14" path="http://mywebsite.com/error/error_page.aspx?id=403" responseMode="Redirect" />
  </httpErrors>

No comments:

Post a Comment