Saturday, February 19, 2011

How to increase the max upload file size in ASP.NET?

I have a form that excepts a file upload in ASP.NET. I need to increase the max upload size to above the 4 MB default.

I have found in certain places referencing the below code at msdn.

[ConfigurationPropertyAttribute("maxRequestLength", DefaultValue = )]

None of the references actually describe how to use it, and I have tried several things with no success. I only want to modify this attribute for certain pages that are asking for file upload.

Is this the correct route to take? And how do I use this?

From stackoverflow
  • If its windows 2003 / IIS 6.0 then check out AspMaxRequestEntityAllowed = "204800" in the file metabase.xml located in folder C:\windows\system32\inetsrv\

    The default value of "204800" (~205Kb) is in my opinion too low for most users. Just change the value to what you think should be max.

    If you cant save the file after editing it you have to either stop the ISS-server or enable the server to allow editing of the file:

    alt text

    Edit: I did not read the question correct (how to set the maxrequest in webconfig). But this informatin may be of interrest for other people, many people who move their sites from win2000-server to win2003 and had a working upload-function and suddenly got the Request.BinaryRead Failed error will have use of it. So I leave the answer here.

  • I hate to refer to my own employer's web site but here is a link you may find useful: http://www.telerik.com/help/aspnet-ajax/upload_uploadinglargefiles.html

  • I believe this line in the web.config will set the max upload size:

    <system.web>
    
         <httpRuntime maxRequestLength="600000"/>
    </system.web>
    
  • This setting goes in your web.config file. It affects the entire application, though... I don't think you can set it per page.

    <configuration>
      <system.web>
        <httpRuntime maxRequestLength="xxx" />
      </system.web>
    </configuration>
    

    "xxx" is in KB. The default is 4096 (= 4 MB).

    Eddie : This got me working for site wide. I set it to 10240 (or 10 MB) for now. Thanks!

0 comments:

Post a Comment