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 帮助页。

若要确保在由 HttpsHelpPageUrl 属性控制的位置发布 HTML 帮助页,您必须将此属性设置为 true,并且必须满足以下条件之一:

  • HttpsHelpPageUrl 属性是支持 HTTP 协议方案的绝对地址。

  • 服务有支持 HTTP 协议方案的基址。

尽管为 HttpsHelpPageUrl 属性指定不支持 HTTP 协议方案的绝对地址会引发异常,但不满足前面两个条件的任何其他方案都不会引发异常,也不会发布 HTML 帮助页。

适用于