HttpError iis config throws an exception when a default path is added

I have this configuration that 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 catch all

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

Server throws 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 msdn documentation

Any help would be greatly appreciated!

+7
web-config iis-7 custom-error-pages
source share
3 answers

Using the defaultPath attribute prevents the use of the path attribute in your error nodes. So the below configuration will work (but, of course, it will show the same error page for all HTTP errors defined here):

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

Associated document: https://msdn.microsoft.com/en-us/library/ms690576(v=vs.90).aspx

+8
source

You cannot override the httpErrors attribute "defaultPath" in IISExpress because applicationhost.config has blocked this attribute:

 <httpErrors lockAttributes="allowAbsolutePathsWhenDelegated,defaultPath"> 

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

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

+4
source

Try defaultPath="~/Error/ApplicationError" with ~.

-one
source

All Articles