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
If you use sharepoint you should configure max size with Administrative Tools too: kb925083
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).
for a 2 GB max limit, on your application 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>
I believe this line in the web.config will set the max upload size:
<system.web>
<httpRuntime maxRequestLength="600000"/>
</system.web>
For IIS 7+, as well as adding the httpRuntime maxRequestLength setting you also need to add:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="52428800" /> <!--50MB-->
</requestFiltering>
</security>
</system.webServer>
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)"
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:
(source: itmaskinen.se)
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.