Problem
In ASP.NET, I have a form that accepts a file upload. I need to increase the maximum upload size beyond the default of 4 MB.
I’ve seen references to the code below on msdn in a few places.
[ConfigurationPropertyAttribute("maxRequestLength", DefaultValue = )]
None of the references explain how to use it, and I’ve tried a few different approaches with no luck. This attribute should only be changed for pages that request a file upload.
Is this the best course of action? And what am I going to do with it?
Asked by Eddie
Solution #1
This option is found in the web.config file. However, it has an impact on the overall application… I don’t believe it’s possible to set it per page.
<configuration>
<system.web>
<httpRuntime maxRequestLength="xxx" />
</system.web>
</configuration>
“xxx” is a KB value. 4096 (= 4 MB) is the default value.
Answered by Eric Rosenberger
Solution #2
You must also add the following to IIS 7+ in addition to the httpRuntime maxRequestLength setting:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="52428800" /> <!--50MB-->
</requestFiltering>
</security>
</system.webServer>
Alternatively, in IIS (7):
Answered by 4imble
Solution #3
There are two ways to increase the upload file size limit.
1. IIS6 or a lesser version
Set maxRequestLength to “15360” if you want to limit uploads to 15MB (15 x 1024).
<system.web>
<!-- maxRequestLength for asp.net, in KB -->
<httpRuntime maxRequestLength="15360" ></httpRuntime>
</system.web>
2. IIS7 or higher is required.
Set maxRequestLength to “15360” and maxAllowedContentLength to “15728640” if you want to limit uploads to 15MB (15 x 1024 x 1024).
<system.web>
<!-- maxRequestLength for asp.net, in KB -->
<httpRuntime maxRequestLength="15360" ></httpRuntime>
</system.web>
<system.webServer>
<security>
<requestFiltering>
<!-- maxAllowedContentLength, for IIS, in bytes -->
<requestLimits maxAllowedContentLength="15728640" ></requestLimits>
</requestFiltering>
</security>
</system.webServer>
https://msdn.microsoft.com/en-us/library/e1f13641(VS.80).aspx MSDN Reference
Answered by Malik Khalil
Solution #4
This line in Web.config, I assume, will set the maximum upload size:
<system.web>
<httpRuntime maxRequestLength="600000"/>
</system.web>
Answered by ben
Solution #5
For a 2 GB maximum restriction, set the following in your application’s web.config:
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" maxRequestLength="2147483647" executionTimeout="1600" requestLengthDiskThreshold="2147483647" />
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647" />
</requestFiltering>
</security>
</system.webServer>
Answered by cangosta
Post is based on https://stackoverflow.com/questions/288612/how-to-increase-the-max-upload-file-size-in-asp-net