我GOOGLE了很多关于这个问题。有很多解决方案,但没有为我工作。我试图使用WCF服务上传图片文件。小图像上传得很好,但一旦尺寸增加,就会发出错误。下面是我得到WCF服务错误,同时上传大图像 - 远程服务器返回意外的响应:(413)请求实体太大
the remote server returned an unexpected response: (413) request entity too large
,并在这里的错误是我的web.config(我相信它的东西做的web.config文件)
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp automaticFormatSelectionEnabled="true" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- 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="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<protocolMapping>
<add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
<serviceActivations>
<add factory="System.ServiceModel.Activation.WebServiceHostFactory" relativeAddress="WebService.svc" service="ChargeMe.Service.WebService"></add>
</serviceActivations>
</serviceHostingEnvironment>
</system.serviceModel>
服务合同:
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
ResponseBase SaveAlertSettings(AlertSettingInfo alertSettingInfo);
AlertSettingInfo.fileToUpload
有base64string首先转换为流,然后作为图像文件写入服务器。它适用于小尺寸图像文件。针对较大文件(如4 MB图像文件)引发错误。
你能告诉我们你的服务合同? – MickyD 2014-10-07 09:27:21
@ User52784246已更新 – iJade 2014-10-07 09:31:31
谢谢。所以,** SaveAlertSettings()**上传图片?也许显示我们** AlertSettingInfo **太请如此 – MickyD 2014-10-07 09:34:18