我们曾经在 WCF Web API 配置中拥有这些属性。
MaxBufferSize = int.MaxValue,
MaxReceivedMessageSize = int.MaxValue,
我们曾经在 WCF Web API 配置中拥有这些属性。
MaxBufferSize = int.MaxValue,
MaxReceivedMessageSize = int.MaxValue,
如果您是自托管的,它是 HttpSelfHostConfiguration 类的一部分: MSDN Documentation of the HttpSelfHostConfiguration class
它将像这样使用:
var config = new HttpSelfHostConfiguration(baseAddress);
config.MaxReceivedMessageSize = int.MaxValue;
config.MaxBufferSize = int.MaxValue;
您可能想查看ASP.NET 应用程序的 web.config 中的httpRuntime部分。它们的名称并不完全相同,但您尝试做的事情可能有一个类似物。例如:
<configuration>
<system.web>
<httpRuntime maxRequestLength="16384" requestLengthDiskThreshold="16384"/>
</system.web>
</configuration>
注意:Int32.MaxValue为 2,147,483,647
首先我会在 WCF App.config 中完成这个配置
<endpoint address ="" binding="basicHttpBinding" bindingConfiguration="basicHttp" contract="AddSubService.IService1">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<!-- Metadata Endpoints -->
<!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
<!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="basicHttp" allowCookies="true"
maxReceivedMessageSize="20000000"
maxBufferSize="20000000"
maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32"
maxArrayLength="200000000"
maxStringContentLength="200000000"/>
</binding>
</basicHttpBinding>
</bindings>
然后尝试更新在 web.config 中调用 WCF 的 ASP.NET 端的引用,检查端点是否已更改为相同。
我解决了这个问题,之前像这样进行动态绑定
BasicHttpBinding bind = new BasicHttpBinding();
bind.OpenTimeout = bind.CloseTimeout = bind.SendTimeout = bind.ReceiveTimeout = new TimeSpan(0, 30, 0);
bind.MaxBufferSize = int.MaxValue;
bind.MaxReceivedMessageSize = int.MaxValue;