Sunday, June 20, 2010

SilverLight WCF Size Problem



Hello;
I've been recently developing an application using Silverlight 4 as with WCF service back end, so some of the functionalities in the project required to upload dome files and store them in a database, but I had a problem reagrding the size of the uploaded file, after googling a lot; all sites were talking about the configuration of the WCF service and the client (you know maxReceivedMessageSize and maxBufferSize="2147483647" and so...); but after changing the configuration it seemed that the problem remains.

The exception I kept receiving when the file is about 3 MB is:

System.ServiceModel.CommunicationException was unhandled by user code
Message=The remote server returned an error: NotFound…

Today I found out the solution in some site; it has nothing to do with the configuration of the WCF and SL client; it is related to the httpRuntime in system.web :)

So if you had the same problem just add this in system.web in your service config file:


<httpRuntime maxRequestLength="2097151" executionTimeout="1000"/>

and of course the configuration in the WCF must allow large files:

Server:
<basicHttpBinding>
        <binding name="silverLightBinding"
                 maxReceivedMessageSize="2147483647" maxBufferSize="2147483647"
                 sendTimeout="0:1:0">
                 <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
        binding>
basicHttpBinding>

Client:
<bindings>
     <basicHttpBinding>
              <binding name="BasicHttpBinding_IDataManager"
                      maxBufferSize="2147483647"
                      maxReceivedMessageSize="2147483647">
               
                <security mode="None" />
              binding>
            basicHttpBinding>
bindings>

I hope that was useful…
Regards;

No comments: