oekstrem
oekstrem

Reputation: 477

HttpError will not show custom error pages

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?

Upvotes: 12

Views: 22126

Answers (5)

favo
favo

Reputation: 69

If you are using ExecuteURL, the custom error page path must be in the same application pool as the application itself.

For architectural reasons, IIS 7.0 can only execute the URL if it is located in the same Application Pool. Use the redirect feature to execute a Custom Error in a different Application Pool.

Upvotes: 5

JPC
JPC

Reputation: 432

Ensure that you have the proper feature setting for the Error Page redirection in IIS. To check this, from the Error Pages page in IIS Manager, click Edit Feature Settings and make sure Custom error pages is checked if you are testing the redirects from the web server itself. If you are testing remotely, you can leave Detailed errors for local requests and custom error pages for remote requests is checked. This appears to be the default option in my test environment.

Upvotes: 0

michael_hook
michael_hook

Reputation: 2046

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>

Upvotes: 20

Freddy
Freddy

Reputation: 3274

This is how I am using it and it works to me, it looks pretty similar except for the subStatusCode directives and the ExecuteURL.


<httpErrors>
     <!--Remove inherited 500 error page setting -->
     <remove statusCode='500' subStatusCode='-1'/> 
     <!--Override the inherited 500 error page setting with the 'My500.html' as its path-->
     <error statusCode='500' subStatusCode='-1' prefixLanguageFilePath='' path='/My500.html' responseMode='ExecuteURL'/> 
</httpErrors>

Upvotes: 6

Phaedrus
Phaedrus

Reputation: 8421

It seems as though you are using a server relative URL, try setting responseMode="ExecuteURL", from MSDN.

ExecuteURL

Serves dynamic content (for example, an .asp file) specified in the path attribute for the custom error. If responseMode is set to ExecuteURL, the path value has to be a server relative URL. The numeric value is 1.

Redirect

Redirects client browsers to a the URL specified in the path attribute that contains the custom error file. If responseMode is set to Redirect, the path value has to be an absolute URL. The numeric value is 2.

Upvotes: 2

Related Questions