Menu ▼

Posted By :
avatarLearn DotNet
Total Views : 993

Custom Error Page (404&403) Handling in IIS7

Step1: In web.config file Write the following code


<customErrors mode="On">

          <error statusCode="404" redirect="PageNotFound.aspx" />

          <error statusCode="403" redirect="PageNotFound.aspx" />




<httpErrors errorMode="Custom" existingResponse="Replace">

          <remove statusCode="404" />

          <remove statusCode="403" />

      <error statusCode="404" path="PageNotFound.aspx" responseMode="Redirect" />

      <error statusCode="403" path="PageNotFound.aspx" responseMode="Redirect" />



Step2: Settings need to be updated in IIS7

 1) Open IIS

2) Select your application

3) Open Error Pages under the IIS section -> clicks Open Features


4) After clicking Open Features tab we will get below shown window. Now click Edit Feature Settings tab

Then we will get below shown window,

In the above window select radio button Custom Error Pages àok



_Open the file:

_And change:

<section name="httpErrors" overrideModeDefault="Deny" />

<section name="httpErrors" overrideModeDefault="Allow" />