我正在開發一個項目。該網站建立在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