Upload large file of size more than 5 MB from Silverlight to Server location using WCF

This post is based on post File Upload from Silverlight using WCF. So please read it before proceeding with this post

Long back I wrote post on uploading a File from Silverlight to server location using WCF. I found my own post quiet useful. However, when I reread and implemented the code, I mentioned in the post, I found few discrepancies

  1. Code was unable to upload file with sizes in MB
  2. There was a bug in binding configuration

In this post, I am going to rectify above two bugs.

First modify basicHttpBinding as below,


Configure Endpoint as below,


So far everything is fine and if you run the code, you would able to upload a file maximum of the size 3MB. I tested and I was able to upload document file of size 2.75 MB.

Now question comes, what if we want to upload a file of the size around 10 MB?

For that we need to reconfigure the things in configuration file

  1. Configure service behavior maximum number of items to serialize or deserialize.
  2. Configure HTTP Request length limit.

You need to explicitly configure the behavior of service to the maximum number of items to serialize or deserialize. This can be configured either in code or in configuration file.

MaxItemsInObjectGraph property of DataContractSerilalizer determines number of items can be serizlized or deserizlized.


Http Request limit can be configured as below


After completing above changes configuration file at service would look like below,

<?xml version="1.0"?>



    <compilation debug="true" targetFramework="4.0" />

    <httpRuntime maxRequestLength="10240" />





        <binding name="ServicesBinding"








                    maxStringContentLength="2147483647" />





      <service name="ServiceData.Service1" behaviorConfiguration="ServiceData.Service1Behavior">

        <endpoint address="" binding="basicHttpBinding" contract="ServiceData.IService1" bindingConfiguration ="ServicesBinding" >


            <dns value="localhost"/>



        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>





        <behavior name ="ServiceData.Service1Behavior">

          <serviceMetadata httpGetEnabled="true"/>

          <serviceDebug includeExceptionDetailInFaults="false"/>

          <dataContractSerializer maxItemsInObjectGraph ="2147483647"/>




    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />



    <modules runAllManagedModulesForAllRequests="true"/>



Now you should able to upload a large file as of size 10 MB from Silverlight client to the server location using WCF Smile


Add to FacebookAdd to DiggAdd to Del.icio.usAdd to StumbleuponAdd to RedditAdd to BlinklistAdd to TwitterAdd to TechnoratiAdd to Yahoo BuzzAdd to Newsvine

6 responses to “Upload large file of size more than 5 MB from Silverlight to Server location using WCF”

  1. I have achieved the same scenario by changing it to CustomBinding with Tranfermode “Streamed” http protocol.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s