Delegating errorMode in httpErrors

Published on March 19, 2008 by walterov

Updated on March 25, 2008 by walterov

Average Rating  Rate It (0)

RSS

There are cases when a hoster may need to delegate to its customers specific settings in the “applicationhost.config” file without delegating the entire section, the errorMode setting in the httpErrors section is one of them, another one is the scriptErrorSentToBrowser setting in the ASP section. For troubleshooting purposes, a hoster’s customer may want to show Detailed Errors in remote clients. To enable it, the hoster would need to lock all attributes except errorMode (lockAllAttributesExcept="errorMode") and lock the error element (lockElements="error"). This way customers can change errorMode from "detailedLocalOnly" to "Detailed" and they would get Detailed Errors for all of their errors.

Note: for security purposes you should not unlock the entire httpErrors section.

To Delegate the errorMode setting:

1. Allow the delegation of the <httpErrors> section in applicationhost.config via overrideModeDefault by opening "%windir%\system32\inetsrv\config\applicationhost.config" with a text editor and changing the <section name="httpErrors" overrideModeDefault="Deny" /> element as follows:

<section name="httpErrors" overrideModeDefault="Allow" />

2. Use lockAllAttributesExcept and lockElements to only allow the delegation of the errorMode setting, locate the <httpErrors> element and change as follows:

<httpErrors lockAllAttributesExcept="errorMode" lockElements="error" > 

   Your httpErrors section might look like this after the change:

<httpErrors lockAllAttributesExcept="errorMode" lockElements="error"> 
  <error statusCode="401" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="401.htm" />
  <error statusCode="403" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="403.htm" />
  <error statusCode="404" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="404.htm" />
  <error statusCode="405" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="405.htm" />
  <error statusCode="406" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="406.htm" />
  <error statusCode="412" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="412.htm" />
  <error statusCode="500" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="500.htm" />
  <error statusCode="501" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="501.htm" />
  <error statusCode="502" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="502.htm" />
</httpErrors> 

3. Now you as the hoster can use appcmd to set the errorMode setting to "Detailed" or "Custom" (see example below)

%windir%\system32\inetsrv\appcmd set config "Default Web Site" -section:httpErrors -errorMode:Detailed

   or you could ask your customers to put the following statement in their web.config files:

<system.webServer>
   <httpErrors errorMode="Detailed"/>
</system.webServer>

Resources

For more information see:

Comments

You must Log In to comment.

Page view counter