C# 使用带有Ajax请求的Wcf服务时出现配置文件错误

C# 使用带有Ajax请求的Wcf服务时出现配置文件错误,c#,ajax,wcf,jquery,C#,Ajax,Wcf,Jquery,我在使用jquery使用WCF服务时遇到了一个问题。我在system.serviceModel/bindings/webHttpbinding中遇到错误“Configuration binding extension”“system.serviceModel/bindings/webHttpbinding”。请验证此绑定扩展已在system.serviceModel/extensions/bindingExtensions中正确注册,并且拼写正确 这是我的Web.Config文件: <sy

我在使用jquery使用WCF服务时遇到了一个问题。我在system.serviceModel/bindings/webHttpbinding中遇到错误“Configuration binding extension”“system.serviceModel/bindings/webHttpbinding”。请验证此绑定扩展已在system.serviceModel/extensions/bindingExtensions中正确注册,并且拼写正确

这是我的Web.Config文件:

<system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <bindings>
      <webHttpBinding>
        <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" />
      </webHttpBinding>
    </bindings>
    <behaviors>
      <endpointBehaviors>
        <behavior name="RestfulServiceBehavior">
          <webHttp helpEnabled="true"/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="WebServiceBehavior">

          <!-- 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>
    </behaviors>
    <services>
      <service name="WcfService1.RestfulServiceImp" behaviorConfiguration="WebServiceBehavior">
        <endpoint address="" behaviorConfiguration="RestfulServiceBehavior" 
             bindingConfiguration="webHttpBindingWithJsonP" binding="webHttpbinding" contract="WcfService1.IRestfulServiceImp"/>
        <!--<endpoint address="mex" binding="mexHttpBinding" contract="WcfService1.IRestfulServiceImp"/>-->
        <endpoint address="soap" binding="basicHttpBinding" contract="WcfService1.IRestfulServiceImp"/>
      </service>
    </services> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"  aspNetCompatibilityEnabled="false"/>

  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="*" />
        <add name="Access-Control-Allow-Headers" value="Content-Type" />
      </customHeaders>
    </httpProtocol>
  </system.webServer>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel"
          switchValue="Information, ActivityTracing"
          propagateActivity="true">
        <listeners>
          <add name="xml"
   type="System.Diagnostics.XmlWriterTraceListener"
   initializeData="c:\log\Traces.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

这是我的服务名RestfulServiceImp,我的合同是IRestfulServiceImp 请您就这些问题提出宝贵的建议


提前感谢。

我现在没有打开的VS可以查看,但请确保该案例并不重要

'system.serviceModel/bindings/webHttpbinding
vs


编辑:所以我打开了VS并将绑定名称改为小写,得到了相同的错误。尝试修正你的案例差异


您的配置中存在大小写不匹配

<bindings>
      <webHttpBinding>
        <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" />
      </webHttpBinding>
    </bindings>


检查webHttpBinding中的大小写差异。。您使用了webHttpbinding而不是webHttpbinding。

<bindings>
      <webHttpBinding>
        <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true" />
      </webHttpBinding>
    </bindings>
<endpoint address="" behaviorConfiguration="RestfulServiceBehavior" 
             bindingConfiguration="webHttpBindingWithJsonP" binding="webHttpbinding" contract="WcfService1.IRestfulServiceImp"/>
        <!--<endpoint address="mex" binding="mexHttpBinding" contract="WcfService1.IRestfulServiceImp"/>-->
        <endpoint address="soap" binding="basicHttpBinding" contract="WcfService1.IRestfulServiceImp"/>