原因在於沒有設定WFC支援Http行為
解決方案是將webconfig檔案改成下面的格式:
<?xml version="1.0"?><configuration> <system.web> <compilation debug="true" targetFramework="4.0" /> </system.web> <system.serviceModel> <protocolMapping> <add scheme="http" binding="webHttpBinding"/> </protocolMapping> <behaviors> <serviceBehaviors> <behavior> <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> <serviceMetadata httpGetEnabled="true"/> <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior> <webHttp/> </behavior> </endpointBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration>
關鍵在
<system.serviceModel> <protocolMapping> <add scheme="http" binding="webHttpBinding"/> </protocolMapping> <behaviors><system.serviceModel>
和
<system.serviceModel> ----- </protocolMapping> <behaviors> <endpointBehaviors> <behavior> <webHttp /> </behavior > </endpointBehaviors> <behaviors> ------<system.serviceModel>
參考來源:stackoverflow