Custom Error Page (404&403) Handling in IIS7

Step 1: In web.config file Write the following code
<system.web> <customErrors mode="On"> <error statusCode="404" redirect="PageNotFound.aspx" /> <error statusCode="403" redirect="PageNotFound.aspx" /> </customErrors> </system.web> <system.webServer> <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" /> </httpErrors> </system.webServer>

Step 2: 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
  5. Then we will get below shown window
In the above window select radio button Custom Error Pages àok

Step 3:
Open the file:

And change: