ServiceDebugBehavior.IncludeExceptionDetailInFaults Eigenschap

Definitie

Hiermee wordt een waarde opgehaald of ingesteld die aangeeft of beheerde uitzonderingsgegevens moeten worden opgenomen in de details van SOAP-fouten die worden geretourneerd naar de client voor foutopsporing.

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

Waarde van eigenschap

true als Windows Communication Foundation (WCF) beheerde uitzonderingsgegevens retourneert in de SOAP-fouten voor clientfoutopsporingsdoeleinden; anders false. De standaardwaarde is false.

Voorbeelden

In het volgende codevoorbeeld ziet u hoe u een configuratiebestand gebruikt om de HTML Help-paginafunctie in te schakelen en uitzonderingsgegevens in een SOAP-fout terug te sturen naar de client voor foutopsporing. Dit configuratiebestand bevat de volgende basisstappen voor het toevoegen van ondersteuning voor de ServiceDebugBehavior functies:

<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>

Opmerkingen

Stel de IncludeExceptionDetailInFaults eigenschap in om WCF opdracht te true geven om beheerde uitzonderingsgegevens te retourneren aan de client in SOAP-fouten om foutopsporing te vereenvoudigen.

Caution

Het retourneren van beheerde uitzonderingsinformatie aan clients kan een beveiligingsrisico zijn, omdat met uitzonderingsdetails informatie wordt weergegeven over de interne service-implementatie die kan worden gebruikt door onbevoegde clients. Hoewel de ServiceDebugBehavior eigenschappen ook programmatisch kunnen worden ingesteld, kan het gemakkelijk zijn om IncludeExceptionDetailInFaults te vergeten uit te schakelen bij het implementeren.

Vanwege de betrokken beveiligingsproblemen wordt ten zeere aangeraden:

  • U gebruikt een toepassingsconfiguratiebestand om de waarde van de IncludeExceptionDetailInFaults eigenschap in te stellen op true.

  • U doet dit alleen in beheerde foutopsporingsscenario's.

Zie Opgeven en afhandelen van fouten in contracten en services voor meer informatie.

Van toepassing op