Share via


ServiceDebugBehavior.HttpHelpPageEnabled 屬性

定義

取得或設定值,控制 Windows Communication Foundation (WCF) 是否在由 HttpHelpPageUrl 屬性控制的位址發佈 HTML 說明頁。

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

屬性值

如果 WCF 發行 HTML 說明頁,則為 true,否則為 false。 預設為 true

範例

下列程式碼範例示範如何使用組態檔來啟用 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>

備註

HttpHelpPageEnabled 屬性設為 false,以停用 HTML 瀏覽器可見的 HTML 說明頁的發行。

如果要確保 HTML 說明頁是在由 HttpsHelpPageUrl 屬性控制的位置發行,必須將這個屬性設定為 true,而且下列條件中必須有一個成立:

  • HttpsHelpPageUrl 屬性是支援 HTTP 通訊協定配置的絕對位址。

  • 有支援 HTTP 通訊協定配置的服務的基底位址。

如果將不支援 HTTP 通訊協定配置的絕對位址指派至 HttpsHelpPageUrl 屬性,將會擲回例外狀況,但是其他任何不符合前述條件的情況都會造成沒有例外狀況和沒有 HTML 說明頁。

適用於