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?
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 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)"