没有与给定的地址“{0}”匹配的协议绑定。协议绑定在 IIS 或 WAS 配置中的站点级别配置。

报这个错说明配置文件没有配置正确

以下使用的是.Net Framwork4 框架。


Web.config文件

错误范例:

<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?>
<configuration>

  <system.web>
    <compilation debug="false" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WCFServiceApp.User">
        <span style="color:#FF0000;"><endpoint address="http://localhost:8001/Service.svc"</span>
          binding="basicHttpBinding" bindingConfiguration="" contract="WCFServiceApp.IUser" />
        <endpoint binding="wsHttpBinding" bindingConfiguration="" contract="WCFServiceApp.IUser" />
        <endpoint address="basic" binding="basicHttpBinding" bindingConfiguration=""
          contract="WCFServiceApp.IUser" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息-->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  
</configuration></span>


正确范例:

<span style="font-size:18px;"><?xml version="1.0" encoding="utf-8"?>
<configuration>

  <system.web>
    <compilation debug="false" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service name="WCFServiceApp.User">
        <span style="color:#FF0000;"><endpoint address="/Service.svc"</span>
          binding="basicHttpBinding" bindingConfiguration="" contract="WCFServiceApp.IUser" />
        <endpoint binding="wsHttpBinding" bindingConfiguration="" contract="WCFServiceApp.IUser" />
        <endpoint address="basic" binding="basicHttpBinding" bindingConfiguration=""
          contract="WCFServiceApp.IUser" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- 为避免泄漏元数据信息,请在部署前将以下值设置为 false 并删除上面的元数据终结点 -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- 要接收故障异常详细信息以进行调试,请将以下值设置为 true。在部署前设置为 false 以避免泄漏异常信息-->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="false" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
  
</configuration>
</span>






你可能感兴趣的:(IIS,WCF,网站发布)