ASP.NET 2.0 FileUpload control - cannot upload more than 4MB by default

I had been wondering. How come my asp.net 2.0 fileupload control can select my jpg image and not my avi video? So I had been wondering, was it that asp.net 2.0 file control could not support avi file extension? That was kinda of crap. I couldn't believe Microsoft would do that right. To prove me wrong. 

So I had decided to search the web again. Geez...

I found out a good tutorial here http://www.c-sharpcorner.com/UploadFile/mahesh/FileUpload10092005172118PM/FileUpload.aspx?ArticleID=79850d6d-0e91-4d7b-9e27-a64a09b0ee6b

He demonstrated that by default you were only able to upload < 4MB.

"The default size of files uploaded by the FileUpload control is 4MB. So if you try to upload the files larger than 4MB, it won't let you do so. To do so, you need to change the default file size in machine.config.comments file for maxRequestLength of httpRuntime tag.  This number is in KB." by Mahesh Chand (from the original article)

So I did learned something from here.

However, he had suggested to modify as below:

"To do so, you need to change the default file size in machine.config.comments file for maxRequestLength of httpRuntime tag.  This number is in KB.

<httpRuntime
executionTimeout = "110" [in Seconds][number
maxRequestLength = "4096" [number]
requestLengthDiskThreshold = "80" [number]
useFullyQualifiedRedirectUrl = "false" [true|false]
minFreeThreads = "8" [number]
minLocalRequestFreeThreads = "4" [number]
appRequestQueueLimit = "5000" [number]
enableKernelOutputCache = "true" [true|false]
enableVersionHeader = "true" [true|false]
apartmentThreading = "false" [true|false]
requireRootedSaveAsPath = "true" [true|false]
enable = "true" [true|false]
sendCacheControlHeader = "true" [true|false]
shutdownTimeout = "90" [in Seconds][number]
delayNotificationTimeout = "5" [in Seconds][number]
waitChangeNotification = "0" [number]
maxWaitChangeNotification = "0" [number]
enableHeaderChecking = "true" [true|false]
/>" by Mahesh Chand.

So I went into my root directory C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG and tried to open that file machine.config.comments file. I tried to search for the keywords as above, and I really could not able to find any. I wondered for a while.

Am I missing something? Am I on a wrong version?

Finally I decided to google again (man, I like the term google). So I found out from here http://channel9.msdn.com/ShowPost.aspx?PostID=106570 This person recommended on this:

"I had this issued when migrating my ASP.Net 1.1 site to ASP.Net 2.0. I found that I couldn't receive file uploads larger than around 80K. It worked fine under 1.1 but failed under 2.0.

There is a new attribute to the httpRunTime element in the web.config for ASP.Net 2.0 that specifies a disk buffer. Changing this to 8192 allowed my code to work.

// Include the code below in your web application web.config

<system.web>
<httpRuntime executionTimeout="90" maxRequestLength="20000" useFullyQualifiedRedirectUrl="false" requestLengthDiskThreshold="8192"/>
</system.web>

http://msdn2.microsoft.com/en-us/library/h2e8928c.aspx

My site was on an intranet. If you're deploying publicly you should be aware that increasing these settings can make your site more vulnerable to a DoS attack." by developer

So I guessed I learned something from there. I had tested and it worked now. :) Cool.

Maybe back to the earlier article, you needed to include those httpRuntime tags into the machine.config.comments instead of modifying it (maybe not for a new user like me since he might had added them last time - my assumption).

Cheers.

Published Tuesday, April 25, 2006 10:04 PM by chuawenching

Comments

# re: ASP.NET 2.0 FileUpload control - cannot upload more than 4MB by default

Sunday, April 30, 2006 8:25 PM by kyawlo
<httpRuntime> can be configured in Web.Config as well. Configuration in Web.config is better than Machine.Config because it will not affect the other asp.net web applications.

# ASP.NET 2.0 FileUpload Problems

Thursday, September 27, 2007 2:45 PM by Wely

I was wondering why I got error when I upload big size file (4 or 5 MB). But when 3.9 MB, it worked well.

# Alberto

Wednesday, August 06, 2008 3:01 AM by Gian

b8505992aca7e1a374e17baa74812557

<a href="njdokj.info/.../b8505992aca7e1a374e17baa74812557">">njdokj.info/.../b8505992aca7e1a374e17baa74812557"> njdokj.info/.../b8505992aca7e1a374e17baa74812557 </a>

njdokj.info/.../b8505992aca7e1a374e17baa74812557

[url]njdokj.info/.../b8505992aca7e1a374e17baa74812557[url]