解決WCF(REST)在https出現檔案找不到錯誤

最近發生的問題

在網站掛上https之後

一些WCF(REST)服務出現在https出現檔案找不到錯誤

但http狀態下卻是正常的

發現原來是要對設定黨做一些調整

以下是調整後的範例

  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="Binding" crossDomainScriptAccessEnabled="true">
          <security mode="Transport">
            <transport clientCredentialType="None" />
          </security>
        </binding>
        <binding name="httpbind" crossDomainScriptAccessEnabled="true">
        </binding>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="returnFaults">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="RESTBehavior">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="returnFaults" name="WebRole1.Services.FeedService">
        <endpoint address="" behaviorConfiguration="RESTBehavior" binding="webHttpBinding" bindingConfiguration="Binding" contract="WebRole1.Services.IFeedService"/>
        <endpoint address="" behaviorConfiguration="RESTBehavior" binding="webHttpBinding" bindingConfiguration="httpbind" contract="WebRole1.Services.IFeedService"/>
      </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>

主要是新增binding部分增加支援https的部分

將原本的endpoint分成兩個分別對應http和https的binding

做完修改之後就正常了

參考 傳輸安全性概觀

留言

這個網誌中的熱門文章

IIS 啟用HTTP Strict Transport Security (HSTS)

Azure Web Apps 讀取憑證