Reputation: 4051
Is there any way I can redirect the user to a custom page whenever HTTP Error 403.7 - Forbidden
occurs in my ASP.NET website?
Upvotes: 0
Views: 963
Reputation: 19772
Yes, use your web.config file to set a custom error page:
<customErrors mode="RemoteOnly">
<error statusCode="403.7" redirect="~/ErrorPages/4037.aspx" />
</customErrors>
Please see the following article
This article is also worth a look.
Edit
From your comment I'd say that the status code need to be an integer so change it to:
<customErrors mode="RemoteOnly">
<error statusCode="403" redirect="~/ErrorPages/403.aspx" />
</customErrors>
Edit 2
You can also set CustomError pages in IIS. I'm not sure if it works with sub status though but it is worth a shot.
Upvotes: 2