Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpError iis config throws exception when default path is added

I have this config which works and redirects the following errors correctly

<httpErrors errorMode="Custom" 
        existingResponse="Replace" 
        defaultResponseMode="ExecuteURL" >
  <remove statusCode="403" />
  <remove statusCode="404" />
  <remove statusCode="500" />
  <error statusCode="403" responseMode="ExecuteURL" path="/Error/AccessDenied" />
  <error statusCode="404" responseMode="ExecuteURL" path="/Error/PageNotFound" />
  <error statusCode="500" responseMode="ExecuteURL" path="/Error/ApplicationError" />
</httpErrors>

But when I add the following default path to try to add a catch all

<httpErrors errorMode="Custom" 
        existingResponse="Replace" 
        defaultResponseMode="ExecuteURL" 
        defaultPath="/Error/ApplicationError">

The server throws a web.config error

HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Module     CustomErrorModule

Now this directly contradicts the documentation on msdn

Any help would be greatly appreciated!!

like image 563
Neil Avatar asked Mar 28 '14 10:03

Neil


People also ask

Where do I put httpErrors in web config?

You can configure the <httpErrors> element at the server level in the ApplicationHost. config file and at the site and application level in the appropriate Web. config file.


1 Answers

You cannot override httpErrors "defaultPath" attribute in IISExpress because of applicationhost.config locked that attribute:

<httpErrors lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath">

You can read more about it here: https://support.microsoft.com/en-us/kb/942055 This problem can occur:

when the specified portion of the IIS configuration file is locked at a higher configuration level. To resolve this problem, unlock the specified section, or do not use it at that level. For more information on configuration locking, see How to Use Locking in IIS 7.0 Configuration.

like image 109
Mohamed Mansour Avatar answered Nov 01 '22 15:11

Mohamed Mansour