Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net - post file gives 404 page result even though posted file is well under maxRequestLength

I have a page on my ASP.NET site which uploads files. I have attempted to tweak the web.config file to allow for larger uploads. In my web.config, I set:

<httpRuntime maxRequestLength="2097152" executionTimeout="3600" />

On my page, when I attempt to upload smaller files, no issue...even at 25MB. However, when I attempt to upload a 50MB file, I still get a 404 error page.

NOTE: I have a flash control on a different page which can upload almost 2gb with no issues, using this same web.config setting. Same result on different PCs, same result when posted to different web servers. My web server is Windows Server 2008 R2.

Any ideas of the cause? Why would flash be ok, but plain jane upload control have this problem?

like image 237
pearcewg Avatar asked Jun 22 '11 20:06

pearcewg


People also ask

How do I reduce file size upload on server?

To control whether the file to upload is temporarily stored in memory or on the server while the request is being processed, set the requestLengthDiskThreshold attribute of the httpRuntime element. This attribute enables you to manage the size of the input stream buffer. The default is 256 bytes.

What is the default size limitation of file upload in asp net Fileupload control?

The property, maxRequestLength indicates the maximum file upload size of 28.6MB, supported by ASP.NET. You cannot upload the files when the FileSize property is below the maxRequestLength value.

Is ASP Net Max file upload size?

Max Upload File Size in IIS and ASP.NET (. By default maximum upload size is set to 4096 KB (4 MB) by ASP.NET. To increase the upload limit add an appropriate section to your web.


2 Answers

I found the answer. Windows Server 2008 R2 is using IIS7 (of course), and in IIS7, you have to set the following in your web.config file (in my example to increase the limit to 2gb):

 <system.webserver>
   <security>
     <requestFiltering>
       <requestLimits maxAllowedContentLength="2147483648" />
     </requestFiltering>
   </security>
 <system.webserver>

This worked, when everything else didn't. IIS7 by default limits uploads to 30mb unless this override is set.

like image 168
pearcewg Avatar answered Oct 06 '22 06:10

pearcewg


The executionTimeout applies only if the debug attribute in the compilation element is False. (see also http://msdn.microsoft.com/en-us/library/e1f13641.aspx)

So try it when starting your application in Release config.

like image 35
Chaim Zonnenberg Avatar answered Oct 06 '22 06:10

Chaim Zonnenberg