Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

When user tries typing any folder from URL (www.mydomain.com/foldername), browser throws following server error "403 - Forbidden: Access is denied.". With this message, attacker can get an idea that there exists such folder name and might try attacking or exploring it. When there is any 403 error, I wanted user to redirect to our custom error page (or 404 Page not found). To achieve this, I have made below settings within my web.config file.
<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL" defaultPath="Common/Error/ErrorHandler.aspx" >
        <remove statusCode="403" />
        <error statusCode="403" path="Common/Error/ErrorHandler.aspx" responseMode="ExecuteURL" />
</httpErrors>


But with this settings, I get HTTP 500 error message with below details.
Most likely causes:
•The website is under maintenance.
•The website has a programming error.

Is the settings made incorrect or is there any issue with the relative path thats been implemented?
Posted
Comments
Maarten Kools 15-Aug-13 10:12am    
Any errors/exceptions in your event log?

1 solution

Using web-config-custom-httperrors[^] as a reference, I noticed a small difference in your config from what is described there. I'm not entirely sure if it is relevant at all, but you are missing subStatusCode="-1" in your remove statement.
 
Share this answer
 
Comments
Vipul Mehta 15-Aug-13 15:27pm    
I implemented below settings but now I get 404 Page not found error. We have this page within application root folder. Is this something to do with the IIS version on our server?

<httperrors errormode="Custom">
<remove statuscode="403" substatuscode="-1">
<error statuscode="403" path="/Blank.htm" responsemode="ExecuteURL">
fjdiewornncalwe 15-Aug-13 15:53pm    
Do you have a page located at the /errors/403.htm path on your site? If not, you must ensure that a 403.htm file exists in the /errors/ folder at the root of your application.
Vipul Mehta 15-Aug-13 16:32pm    
Yes my page exists there. Following are my server details

OS - Server 2008 Enterprise SP2
IIS - 7.0
App Pool framework version - v2.0


Is this something to do with the App pool framework version?

Below is my latest web config settings with Blank.htm file exists on the application root folder.
<pre lang="xml">
<httperrors errormode="Custom">
<remove statuscode="403" substatuscode="-1">
<error statuscode="403" path="/Blank.htm" responsemode="ExecuteURL">
</error></remove></httperrors>

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



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