我必须将 2 张图片发送到我的 Web 服务,这会将它们添加到 Word 文档中。
目前,我将图像作为 base64
发送。
当我只发送 1 张图片时,没有问题,但是当我发送 2 张图片(我可以发送的最大值)时,chrome 崩溃了。 (“哇咔嚓,……”)。
当我尝试发送 2 x 762 KB 图像时它崩溃了。 尝试使用 1KB 的图像时,它有效。
我应该发送字节数组而不是 base 64 吗?或者其他方式?
我已经更改了我的 web.config
以允许发送更多数据。
网页配置
<binding name="WebHttpEndpointBinding" transferMode="StreamedRequest" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
编辑
我尝试将它添加到网络配置中,但仍然无法正常工作。
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2000000000" />
</requestFiltering>
</security>
最佳答案
在配置文件中,您必须增加大小以上传大数据,如下所示:
<webHttpBinding>
<binding name="web" maxReceiveMessagesize="250000000" maxBufferSize="250000000" maxBufferPoolSize="250000000" closeTimeout="00:10:00" openTimeout="00:10:00"
receiveTimeout="00:10:00" sendTimeOut="00:10:00">
<readerQuotas maxDepth="250000000" maxStringContentLeangth="250000000" maxArraylength="250000000" maxBytesPerread="250000000"
maxNameTableCharCount="250000000"/>
<security mode="None" />
</binding>
</webHttpBinding>
请检查您是否已经在端点中使用绑定(bind)配置,如下所示:
But it still can not help. Please try to check that you have already used the binding configure in the endpoint as following:
<endpoint address="http://"
binding="webHttpBinding" bindingConfiguration="web"
contract="..." name="..." />
关于c# - WCF Restful 网络服务 |发送图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30162343/