Did you know: Enable Custom Error in IIS 7 / 7.5 - Part 1

by Vivek 12/20/2009 11:46:00 PM

You create a custom error page when you don’t want a regular user to see the actual error message. You can always see a detailed error message when you browse the page locally on the server. There are three ways how you can set custom error page in IIS 7 / 7.5, today we will look at how to set a static file in the error response.

In IIS 6.0

  1. Right click on Web Site (Default Web Site in our case) and click on Properties
  2. Under Custom Errors tab, click on the error page you want to customize (in our case 403;4)
  3. Click Edit… and select the file by clicking on the Browse… button

    image11

In IIS 7 / 7.5

  1. Click on the Web Site (Default Web Site in our case)
  2. In Features View, double click on Error Pages
  3. Click  Add…, under Status code: type 403.4
  4. Click "Insert content from static file into the error response", type custerr\403.4.htm
  5. Click OK

    image12

  6. Now, to set detailed error locally for the 403.4
  7. Click on 403.4 error page we configured and click on Edit Feature Settings…
  8. Under Error Responses, select “Detailed errors for local requests and custom error pages for remote requests”, click OK

     image13

Remember, I have a custerr folder in C:\Inetpub\wwwroot folder.

My web.config:

<httpErrors errorMode="DetailedLocalOnly">
<error statusCode="403" subStatusCode="4" path="custerr\403.4.htm" responseMode="File" />
</httpErrors>

If you are planning to customize the existing error page (in our case 403-4.htm) in the C:\inetpub\custerr\en-US folder. You will need to set the custom error page at the machine level.

My applicationHost.config:

<error statusCode="403" subStatusCode="4" prefixLanguageFilePath="C:\inetpub\custerr" path="403.4.htm" 
responseMode="File" />

 

Hope this helps,
Vivek Kumbhar


Quote of the day:
I'm seventeen and I'm crazy. My uncle says the two always go together. When people ask your age, he said, always say seventeen and insane. - Ray Bradbury

Tags: , , ,

Did you know | IIS 7

blog comments powered by Disqus

Who is Rahul?

Rahul

He works for Microsoft and likes Software & Gadgets!

He shares some interesting notes here while working with stuff that excites him.

Disclaimer

The opinions expressed herein are our own personal opinions and do not represent our employer's view in any way.
© Copyright 2014, Rahul Soni