I'm working on a project. The website was built on MVC, http://www.example.com , recently, another developer added a windows web service (not WCF) to the project, http://www.example.com/WebServices/upload.asmx . It is supposed to for uploading images to server. The Route is added to RouteConfig, so it works:
routes.IgnoreRoute("WebServices/*/{resource}.aspx/{*pathInfo}");
However, I noticed that it works for small size files. When the file size reaches certain point, i.e. > 1MB (not sure the exact #, but 650KB file works and 1.1MB file fails). The error message is:
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:
I searched 2 days, all the solutions I could find did not work. Now, on the site, in web.config, I have:
<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>
We use a desktop application to consume the web service. In the app.config, I have:
<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>
The weird thing is: 600KB file works, but if file size > 1MB, it has this error. BUT, nowhere from these configuration I can find any relation with these numbers.
Anyone knows what the problem is? Any suggestions? Could it because of route in MVC?
Thanks