我正在开发一个项目。该网站建立在MVC http://www.example.com上,最近,另一位开发人员在该项目中添加了一个windows web服务(不是WCF),该项目为http://www.example.com/WebServices/upload.asmx。它应该用于将图像上传到服务器。路由被添加到RouteConfig,所以它的工作原理:System.ServiceModel.ProtocolException:远程服务器返回意外响应:(413)请求实体太大
routes.IgnoreRoute("WebServices/*/{resource}.aspx/{*pathInfo}");
但是,我注意到它适用于小尺寸文件。当文件大小达到某一点时,即> 1MB(不确定确切的#,但650KB文件工作和1.1MB文件失败)。错误信息是:
System.ServiceModel.ProtocolException was caught
HResult=-2146233087
Message=The remote server returned an unexpected response: (413) Request Entity Too Large.
Source=mscorlib
StackTrace:
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at SyncDatabase.eyephoto.com.upload.UploadSoap.UploadImage(UploadImageRequest request)
....
InnerException: System.Net.WebException
HResult=-2146233079
Message=The remote server returned an error: (413) Request Entity Too Large.
Source=System
StackTrace:
at System.Net.HttpWebRequest.GetResponse()
at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
InnerException:
我搜索了2天,我找到的所有解决方案都无法工作。现在,在网站上,在web.config中,我有:
<httpRuntime maxRequestLength="40960000" executionTimeout="300" />
...
<system.serviceModel>
<client />
<bindings>
<basicHttpBinding>
<binding closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
我们使用桌面应用程序来使用Web服务。在App.config,我有:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="UploadSoap1" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647" closeTimeout="00:10:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" >
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://www.example.com/WebServices/Upload.asmx"
binding="basicHttpBinding" bindingConfiguration="UploadSoap1"
contract="mysite.com.upload.UploadSoap" name="UploadSoap1" />
</client>
</system.serviceModel>
奇怪的是:600KB文件的工作,但如果文件大小> 1MB,它有这个错误。但是,从这些配置无处可以找到与这些数字的任何关系。
任何人都知道问题是什么?有什么建议么?是否因为MVC中的路由?
感谢
入住这http://stackoverflow.com/questions/8225736/transfer-large-amount-of-data-in-wcf-service – malkam