Re: What is the MAX file upload size limit in ASP.net 4.0?
Jul 12, 2013 08:16 PM|LINK
You likely will need to update your maxRequestLength within your web.config to handle files and uploads that are large (as the default limit is often 4MB).
It's important to know that maxAllowedContentLength is measured in bytes and maximumRequestLength is measured in kilobytes when settings these values so you'll need to adjust them accordingly if you plan on handling much larger files :
<configuration> <system.web> <!-- This will handle requests up to 1024MB (1GB) --> <httpRuntime maxRequestLength="1048576" timeout="3600" /> </system.web> </configuration> <!-- IIS Specific Targeting (noted by the system.webServer section) --> <system.webServer> <security> <requestFiltering> <!-- This will handle requests up to 1024MB (1GB) --> <requestLimits maxAllowedContentLength="1048576000" /> </requestFiltering> </security> </system.webServer>
Updating the maxRequestLength property is likely going to be the easiest method of handling this, however there are alternatives such as libraries like NeatUpload, which are designed to handle large files and can handle uploading files as streams to your preferred method of storage.
Jon Galloway covers handling large file uploads and several methods of handling them within .NET in this blog post, which would likely be an excellent read related to your topic.
If you are using IIS for hosting your application, then the default upload file size if 4MB. To increase it, please use this below section in your web.config -
<configuration>
<system.web>
<httpRuntime maxRequestLength="1048576" />
</system.web>
</configuration>
For IIS7 and above, you also need to add the lines below:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
</system.webServer>
Note:
maxAllowedContentLength
is measured in bytes while maxRequestLength
is measured in kilobytes, which is why the values differ in this config example. (Both are equivalent to 1 GB.)
No comments:
Post a Comment