Share via


ServiceDebugBehavior.IncludeExceptionDetailInFaults プロパティ

定義

デバッグの目的でクライアントに返される SOAP エラーの詳細に、マネージド例外情報を含めるかどうかを指定する値を取得または設定します。

public:
 property bool IncludeExceptionDetailInFaults { bool get(); void set(bool value); };
public bool IncludeExceptionDetailInFaults { get; set; }
member this.IncludeExceptionDetailInFaults : bool with get, set
Public Property IncludeExceptionDetailInFaults As Boolean

プロパティ値

Boolean

trueWindows Communication Foundation (WCF) がクライアント のデバッグ目的で SOAP エラーでマネージド例外情報を返す場合は .。それ以外の場合は > false 既定値は、false です。

構成ファイルを使用して、HTML ヘルプ ページ機能を有効にし、デバッグのために SOAP エラー内の例外情報をクライアントに返す方法を次のコード例に示します。 この構成ファイルは、ServiceDebugBehavior 機能のサポートを追加するための次の基本手順を示します。

<configuration>
  <system.serviceModel>
    <services>
      <!-- 
        Step 1. Add a behaviorConfiguration attribute
        in the <service> element.
      -->
      <service 
        name="Microsoft.WCF.Documentation.SampleService"
        behaviorConfiguration="metadataAndDebug">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/SampleService" />
          </baseAddresses>
        </host>
        <endpoint
          address=""
          binding="wsHttpBinding"
          contract="Microsoft.WCF.Documentation.ISampleService"
        />
        <endpoint
           address="mex"
           binding="mexHttpBinding"
           contract="IMetadataExchange"
        />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <!-- 
          Step 2. Inside a <serviceBehaviors> section, add 
          a name attribute in the <behaviors> element that 
          matches the behaviorConfiguration attribute in the
          <service> element above.
        -->
        <behavior name="metadataAndDebug">
          <serviceMetadata 
            httpGetEnabled="true" 
            httpGetUrl=""
          />
          <!-- 
            Step 3. Add a <serviceDebug> element and 
            modify the various attributes that suit your 
            scenario.
          -->
          <serviceDebug 
            httpHelpPageEnabled="true" 
            includeExceptionDetailInFaults="true"
          />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

注釈

デバッグを IncludeExceptionDetailInFaults 容易にするために true 、SOAP エラーでマネージ例外情報をクライアントに返すように WCF に指示するようにプロパティを設定します。

注意事項

マネージド例外情報をクライアントに戻すことは、セキュリティ リスクになり得ます。これは、例外の詳細が、非承認のクライアントで使用可能な内部サービスの実装についての情報を公開するからです。 さらに、ServiceDebugBehavior プロパティをプログラムで設定することはできますが、配置するときに IncludeExceptionDetailInFaults を無効にすることを忘れがちになります。

セキュリティの問題にかかわるので、以下を強くお勧めします。

  • IncludeExceptionDetailInFaults プロパティの値を true に設定するには、アプリケーション構成ファイルを使用します。

  • これは、制御されたデバッグ シナリオの場合に限って行います。

詳細については、「コントラクトおよびサービスのエラーの指定と処理」を参照してください。

適用対象