Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpError will not show custom error pages

Tags:

asp.net

iis-7

I've got this in the web.config:

<httpErrors errorMode="Custom">
  <remove statusCode="404" subStatusCode="-1" />
  <remove statusCode="500" subStatusCode="-1" />
  <error statusCode="404" prefixLanguageFilePath="" path="/Error/NotFound.aspx" responseMode="Redirect" />
  <error statusCode="500" prefixLanguageFilePath="" path="/Error/ServerError.aspx" responseMode="Redirect" />
</httpErrors>

But IIS still shows the built in error page.

Any ideas?

like image 230
oekstrem Avatar asked Dec 11 '09 15:12

oekstrem


People also ask

How do I enable custom errors in IIS?

You can add custom error messages to IIS by adding an <error> element to the <httpErrors> element in the Web. config file for your site, application, or URL.

How do I redirect a custom error page in IIS?

Within the text box, “File path,” type the URL of the custom error page, and then click “OK.” Note: Make sure when selecting this option that the path is a relative path. Once you hit “OK,” your custom 404 error page should be live and doing its job.

What is custom error page?

Custom error pages enable you to customize the pages that display when an error occurs. This makes your website appear more professional and also prevents visitors from leaving your site. If a visitor sees a generic error page, they are likely to leave your site.


1 Answers

You may also need to set the existingReponse attribute in the httpErrors element like this:

<httpErrors errorMode="Custom" existingResponse="Replace">
  <clear />
      <error statusCode="404" prefixLanguageFilePath="" path="/ErrorHandler.aspx" responseMode="ExecuteURL" />
  <error statusCode="500" prefixLanguageFilePath="" path="/ErrorHandler.aspx" responseMode="ExecuteURL" />
</httpErrors>
like image 96
michael_hook Avatar answered Oct 05 '22 08:10

michael_hook