httpErrors での errorMode の委任

投稿者: Walter Oliver

警告: この機能は現在、IIS 7.0 で想定どおりに動作していません。次のリリースに向けて対処しているところです。IIS 7.0 では、特定のサイトまたはサーバー全体の HTTP エラーをロックおよびロック解除できますが、現在 "lockAllAttributesExcept="errorMode" は httpErrors では機能しません。ただし、こちらの記事の、IIS 構成のその他のセクションの特定の属性のロックの解除に関するアイデアを使用できます

ホスト側がセクション全体を委任せず、"applicationhost.config" ファイル内の顧客固有の設定に委任する必要がある場合があります。httpErrors セクションの errorMode 設定はそのうちの 1 つであり、もう 1 つは ASP セクションの scriptErrorSentToBrowser 設定です。 トラブルシューティングの目的で、ホスト側の顧客がリモート クライアントで詳細エラーを表示することが必要になる場合があります。 これを有効にするには、ホスト側で errorMode を除くすべての属性をロックし (lockAllAttributesExcept="errorMode")、エラー要素をロックする必要があります (lockElements="error")。 これにより、顧客が errorMode を "detailedLocalOnly" から "Detailed" に変更できるようになり、すべてのエラーについて詳細エラーが表示されます。

errorMode 設定を委任するには、次のようにします。

  1. テキスト エディターで %windir%\system32\inetsrv\config\applicationhost.config を開き、<section name="httpErrors" overrideModeDefault="Deny" /> 要素を次のように変更することで、overrideModeDefault を介して applicationhost.config の <httpErrors> セクションの委任を許可します。

    <section name="httpErrors" overrideModeDefault="Allow" />
    
  2. lockAllAttributesExcept と lockElements を使用して errorMode 設定の委任のみを許可し、<httpErrors> 要素を見つけて、次のように変更します。

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

    変更後、httpErrors セクションは次のようになる場合があります。

    <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. これで、ホスト側として appcmd を使用して errorMode 設定を "Detailed" または "Custom" に設定できるようになりました (下の例を参照)

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

    または、web.config ファイルに次のステートメントを配置するように顧客に依頼することもできます。

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

リソース

詳細については、以下を参照してください。