【问题标题】:Could not find a base address OR maximum string content length quota(8192)? [duplicate]找不到基地址或最大字符串内容长度配额 (8192)? [复制]
【发布时间】:2013-05-20 16:30:48
【问题描述】:

我在 ajax POST 调用中收到 The maximum string content length quota (8192) has been exceeded while reading XML data.。

我在<endpoint> 中添加了bindingConfiguration="UsernameWithTransport",然后还添加了<readerQuotas>,之后我收到了Could not find a base address that matches scheme https for the endpoint with binding WebHttpBinding. Registered base address schemes are [http] 异常。

见下面我的 web.config 文件。

<system.serviceModel>
<behaviors>
  <serviceBehaviors>   
      <behavior name="metadataBehavior">
          <serviceMetadata  httpGetEnabled="true" httpGetUrl="" httpsGetEnabled="false"/>            
          <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
      </behavior>
  </serviceBehaviors>
  <endpointBehaviors>
    <behavior name="Company.CostReduction.EditInitiativesAspNetAjaxBehavior">
      <enableWebScript />
    </behavior>
  </endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
  <service name="Company.CostReduction.EditInitiatives" behaviorConfiguration="metadataBehavior">
      <host>
          <baseAddresses>
              <add baseAddress="http://localhost:57771/EditInitiatives.svc" />
          </baseAddresses>
      </host>
      <endpoint address="" behaviorConfiguration="Company.CostReduction.EditInitiativesAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="UsernameWithTransport" contract="Company.CostReduction.EditInitiatives"  />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<bindings>
  <webHttpBinding>
    <binding name="UsernameWithTransport">
        <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
      <security mode="Transport">
        <transport clientCredentialType="Basic" />
      </security>
    </binding>
  </webHttpBinding>
</bindings>

这里有什么问题?

【问题讨论】:

    标签: asp.net wcf jquery


    【解决方案1】:

    问题从这里开始

      <host>
          <baseAddresses>
              <add baseAddress="http://localhost:57771/EditInitiatives.svc" />
          </baseAddresses>
      </host>
    

    您已在 webHttpBinding 配置中将安全模式选择为“传输”。但是你的基地址是http。应该是https。 (顺便说一句,您不能使用开发服务器托管 https 服务,您需要将其托管在 IIS 中。) 将您的基址更改为:https://localhost:57771/EditInitiatives.svc

    问题在这里继续:

     <behavior name="metadataBehavior">
          <serviceMetadata  httpGetEnabled="true" httpGetUrl="" httpsGetEnabled="false"/>            
          <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
      </behavior>
    

    您将使用传输安全性托管您的服务。所以你需要将 httpGetEnabled 设置为 false 并将 httpsGetEnabled 设置为 true。这是当前配置的相反设置。

    最后,要使用传输安全性托管您的元数据,您还需要在此处进行更改:

    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    

    应该改为:

    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
    

    尝试这些更改并在此处发布您遇到的任何更多错误。

    希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-15
      • 1970-01-01
      相关资源
      最近更新 更多