我在ajax POST调用中得到The maximum string content length quota (8192) has been exceeded while reading XML data.
。
我在bindingConfiguration="UsernameWithTransport"
中添加了<endpoint>
,之后又添加了<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>
这里有什么不对?
答案 0 :(得分:0)
问题从这里开始
<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" />
尝试这些更改并发布您在此处发现的任何错误。
希望这有帮助!