这几天我一直在努力解决这个问题,但无济于事。当我尝试使用 IIS Express 在 Visual Studio 中进行调试以及将我的生产网站部署到运行 IIS 7.5 的机器上时,都会发生这种情况。
我已经使用HttpWebRequest
和在 Fiddler 4 中从 Visual Studio 单元测试中调用了该服务,同样的错误。所以我不认为这是 WCF 客户端配置,因为我没有使用。
无论我在配置文件中进行什么更改,我总是会收到此异常:
"Exception thrown: 'System.ServiceModel.ProtocolException' in
System.ServiceModel.dll
Additional information: The maximum message size quota for incoming messages
(65536) has been exceeded. To increase the quota, use the
MaxReceivedMessageSize property on the appropriate binding element."
我附加的以下 Web.config 用于不在我的服务器根目录中的应用程序。
我正在使用 Ajax 使用 json 端点进行调用。
我一生都无法弄清楚为什么我会获得 64K 限制,尤其是考虑到我已将所有项目添加到webHttpBinding
以下内容中。
我还httpRuntime
通过添加项目更改了元素maxRequestLength
,更改了请求过滤、安全设置以及一系列其他没有影响的事情。
另请注意,我已打开跟踪。.svclog
文件没有告诉我更多信息。
提前感谢您的帮助。
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
<add key="FactoryType" value="Production"/>
<add key="TravelRequestConnectionString" value="Data Source=ITLCS.benderson.com;Initial Catalog=TestTravelRequestSite;User Id=XXXX;Password=XXXXX"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.6.1" />
<httpRuntime targetFramework="4.6.1"/>
<membership defaultProvider="ADMembershipProvider">
<providers>
<clear />
<add name="ADMembershipProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" />
</providers>
</membership>
</system.web>
<system.serviceModel>
<services>
<service name="TravelRequestWebService.TravelRequestService">
<endpoint
address="web"
binding="basicHttpBinding"
contract="TravelRequestWebService.ITravelRequestService" />
<endpoint
address="json"
binding="webHttpBinding"
behaviorConfiguration="jsonBehavior"
contract="TravelRequestWebService.ITravelRequestService" />
<endpoint
address=""
binding="basicHttpBinding"
contract="TravelRequestWebService.ITravelRequestService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="defaultBehavior">
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true"/>
</behavior>
<behavior name="bigBehavior">
<dataContractSerializer maxItemsInObjectGraph="200"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="WebBehavior">
<webHttp/>
</behavior>
<behavior name="jsonBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<webHttpBinding>
<binding name="webHttpBinding" allowCookies="true"
maxReceivedMessageSize="20000000"
maxBufferSize="20000000">
</binding>
</webHttpBinding>
<basicHttpBinding>
<binding name="basicHttpBinding" allowCookies="true"
maxReceivedMessageSize="20000000"
maxBufferSize="20000000">
</binding>
</basicHttpBinding>
</bindings>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
<!--
To browse web app root directory during debugging, set the value below to true.
Set to false before deployment to avoid disclosing web app folder information.
-->
<directoryBrowse enabled="true"/>
</system.webServer>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Information, ActivityTracing"
propagateActivity="true">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="CardSpace">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="System.IO.Log">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="System.Runtime.Serialization">
<listeners>
<add name="xml" />
</listeners>
</source>
<source name="System.IdentityModel">
<listeners>
<add name="xml" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="xml"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\log\Traces.svclog" />
</sharedListeners>
</system.diagnostics>
</configuration>