WCF WEB API配置

Web.config配置

<system.serviceModel>

    <services>

      <service name="WCFServiceWebRole2.Service1">

        <endpoint  contract="WCFServiceWebRole2.IService1" 

                   binding="webHttpBinding"

                   behaviorConfiguration="web"

                  ></endpoint>

      </service>

    </services>

    <behaviors>

      <serviceBehaviors>

        <behavior>

          <!-- 为了避免泄漏元数据信息,请在部署之前将下面的值设置为 false -->

          <serviceMetadata httpGetEnabled="true"/>

          <!-- 要接收错误中的异常详细信息以便进行调试,请将下面的值设置为 true。在部署之前请设置为 false 以避免泄露异常信息-->

          <serviceDebug includeExceptionDetailInFaults="false"/>

        </behavior>

      </serviceBehaviors>

      <endpointBehaviors>

        <behavior name="web">

          <webHttp helpEnabled="true" defaultBodyStyle="Bare" defaultOutgoingResponseFormat="Json" ></webHttp>

        </behavior>

      </endpointBehaviors>

    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

  </system.serviceModel>
behaviorConfiguration="web" 配置为HTTP访问

你可能感兴趣的:(Web)