Problem uploading large files in ASP.NET

12. October 2012 10:35 by Mrojas in General  //  Tags: , , , ,   //   Comments (0)

If you try to upload large files you might get an exception like

HttpException: Maximum request lenght exceeded.

This problem occurs because the default value for the maxRequestLength parameter in the section 

of the machine.config or Web.config file is 4096 (4M).

So any file with a size bigger will fail.

However I think that the max size that you can write here is 2G 2097151

Some info can be found here: http://support.microsoft.com/default.aspx?scid=kb;EN-US;295626

 

So to change that for 512mb use something like:

 

<configuration>

    <system.web>

        <httpRuntime maxRequestLength="524288" /> 

    </system.web>

</configuration>

Huge amounts of data WCF \ Silverlight

18. March 2011 04:03 by Mrojas in General  //  Tags: , , , , , , ,   //   Comments (0)

 

Today I found this excellent post:
http://smehrozalam.wordpress.com/2009/01/29/retrieving-huge-amount-of-data-from-wcf-service-in-silverlight-application/ 
and I was the key to solve a problem I had with a WCF service.

I had made some changes to an application to send a text file to the server
for batch processing, everything was working fine until I started sending big files.

I just received one of those obnoxious Not Found error.
So what could I do? Well as any respectable WCF developer would I started tracing the WCF messages with Fiddler, and I found this:

If you cannot read it from the image the message was:

DeserializationFailed… The formatter threw an exception while trying to deserialize the message:
There was an error while trying to deserialize parameter :_xxxxxx.
The InnerException message was 'There was an error deserializing the object of type System.String.
The maximum string content length quota (8192) has been exceeded while reading XML data.
This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas
object used when creating the XML reader.

I was a little confused but thanks to that post I was able to just add:

          <binaryMessageEncoding maxWritePoolSize="16" maxSessionSize="8192">
            <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
                                   maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          </binaryMessageEncoding>
 
 

And got everything working again!

Categories