locked
Unable to upload file greater than 16KB RRS feed

  • Question

  • User-898093797 posted

    I have a MVC aplication and WCF application in my solution. I'm new to WCF. I'm trying to upload a file in my application. I can upload files lesserthan 16 kb easily If I upload a file greather than 16 KB its showing an error:

    The formatter threw an exception while trying to deserialize the message: Error in deserializing body of request message for operation 'SetData'. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 44640.

    When I tried with 800Kb its showing:

    The remote server returned an unexpected response: (400) Bad Request.

    I have my sample code here: http://db.tt/aVOQLmv4

    My WCF config file is:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
    
      <system.web>
        <compilation debug="true" />
      </system.web>
      <!-- When deploying the service library project, the content of the config file must be added to the host's 
      app.config file. System.Configuration does not support config files for libraries. -->
      <system.serviceModel>
        <services>
          <service name="FileUploadWCF.Service1">
            <host>
              <baseAddresses>
                <add baseAddress = "http://localhost:8732/Design_Time_Addresses/FileUploadWCF/Service1/" />
              </baseAddresses>
            </host>
            <!-- Service Endpoints -->
            <!-- Unless fully qualified, address is relative to base address supplied above -->
            <endpoint address ="" binding="wsHttpBinding" contract="FileUploadWCF.IService1">
              <!-- 
                  Upon deployment, the following identity element should be removed or replaced to reflect the 
                  identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
                  automatically.
              -->
              <identity>
                <dns value="localhost"/>
              </identity>
            </endpoint>
            <!-- Metadata Endpoints -->
            <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. --> 
            <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
            <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior>
              <!-- To avoid disclosing metadata information, 
              set the value below to false and remove the metadata endpoint above before deployment -->
              <serviceMetadata httpGetEnabled="True"/>
              <!-- To receive exception details in faults for debugging purposes, 
              set the value below to true.  Set to false before deployment 
              to avoid disclosing exception information -->
              <serviceDebug includeExceptionDetailInFaults="False" />
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
    
    </configuration>

    Client side config:

    <system.serviceModel>
        <bindings>
          <wsHttpBinding>
            <binding name="WSHttpBinding_IService1" closeTimeout="00:01:00"
              openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
              bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
              maxBufferPoolSize="200000000" maxReceivedMessageSize="200000000" messageEncoding="Text"
              textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
              <readerQuotas maxDepth="32" maxStringContentLength="200000000" maxArrayLength="200000000"
                maxBytesPerRead="200000000" maxNameTableCharCount="200000000" />
              <reliableSession ordered="true" inactivityTimeout="00:10:00"
                enabled="false" />
              <security mode="Message">
                <transport clientCredentialType="Windows" proxyCredentialType="None"
                  realm="" />
                <message clientCredentialType="Windows" negotiateServiceCredential="true"
                  algorithmSuite="Default" />
              </security>
            </binding>
          </wsHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://localhost:8732/Design_Time_Addresses/FileUploadWCF/Service1/"
            binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IService1"
            contract="ServiceReference1.IService1" name="WSHttpBinding_IService1">
            <identity>
              <dns value="localhost" />
            </identity>
          </endpoint>
        </client>
      </system.serviceModel>

    Please help me to resolve this issue.


    Wednesday, December 26, 2012 11:03 PM

Answers

  • User197322208 posted

    see also

    http://weblogs.asp.net/jgalloway/archive/2008/01/08/large-file-uploads-in-asp-net.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 26, 2012 11:49 PM
  • User-1000095884 posted

    Hi,

    You also need to increase the maxStringContentLength on your WCF host app.config/web.config file. You can find example in below blog.

    #Passing large files over WCF channel <!--EndFragment-->

    <!--EndFragment-->http://patrickyong.wordpress.com/2008/07/02/passing-large-files-over-wcf-channel/

    If the issue still exists, please get the detail error message with fiddler.

    Best Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 2, 2013 9:24 PM

All replies

  • User197322208 posted

    see also

    http://weblogs.asp.net/jgalloway/archive/2008/01/08/large-file-uploads-in-asp-net.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 26, 2012 11:49 PM
  • User-1000095884 posted

    Hi,

    You also need to increase the maxStringContentLength on your WCF host app.config/web.config file. You can find example in below blog.

    #Passing large files over WCF channel <!--EndFragment-->

    <!--EndFragment-->http://patrickyong.wordpress.com/2008/07/02/passing-large-files-over-wcf-channel/

    If the issue still exists, please get the detail error message with fiddler.

    Best Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 2, 2013 9:24 PM