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?

3/16/2010 2:08:15 AM

Accepted Answer

This setting goes in your web.config file. It affects the entire application, though... I don't think you can set it per page.

    <httpRuntime maxRequestLength="xxx" />

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

2/18/2014 3:38:21 PM

For IIS 7+, as well as adding the httpRuntime maxRequestLength setting you also need to add:

        <requestLimits maxAllowedContentLength="52428800" /> <!--50MB-->

Or in IIS (7):

  • Select the website you want enable to accept large file uploads.
  • In the main window double click 'Request filtering'
  • Select "Edit Feature Settings"
  • Modify the "Maximum allowed content length (bytes)"

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow