【发布时间】:2014-05-17 06:12:15
【问题描述】:
我正在做一个项目。该网站建立在 MVC 之上,http://www.example.com,最近,另一位开发人员在项目中添加了一个 Windows Web 服务(不是 WCF),http://www.example.com/WebServices/upload.asmx。它应该用于将图像上传到服务器。 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 的文件可以工作,但是如果文件大小> 1MB,就会出现这个错误。但是,从这些配置中我找不到与这些数字的任何关系。
谁知道问题出在哪里?有什么建议?可能是因为 MVC 中的路由?
谢谢
【问题讨论】:
标签: c# asp.net-mvc web-services