我正在开展一个项目。该网站建立在MVC http://www.example.com上,最近,另一位开发人员向项目http://www.example.com/WebServices/upload.asmx添加了一个Windows Web服务(而不是WCF)。它应该用于将图像上传到服务器。 Route已添加到RouteConfig,因此可以正常工作:
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文件有效,但如果文件大小&gt; 1MB,它有这个错误。但是,从这些配置中我无处可以找到与这些数字的任何关系。
有谁知道问题是什么?有什么建议?可能是因为MVC中的路由?
由于
答案 0 :(得分:0)
基于搜索结果进行多次尝试后,由于某些原因,它从未成功过。最大上传文件总是大约600KB,不知道#来自哪里。我怀疑是因为我在MVC项目中使用传统的asmx Web服务。
最后,我决定这样做:
这不是最好的方法,但至少它是有效的。我们可以选择选择框架尺寸。
感谢