.NET MVC3 Can't upload large files via FileUpload
I need a way to upload large files (50+ MB) on my .net mvc3 website (hosted on Amazon). After downloading a large zip file (36.9 MB), FireFox shows "Connection has been reset" and FireBug shows "Canceled" in status.
Any ideas on how I can solve this?
Controller:
private void SaveFile(HttpPostedFileBase uploadedFile)
{
using (var file = System.IO.File.Create(Server.MapPath("/uploads/" + uploadedFile.FileName))
uploadedFile.InputStream.CopyTo(file);
}
Web.config:
<system.web>
<httpRuntime maxRequestLength="56320" executionTimeout="1500"/>
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength= "10485760"/>
</requestFiltering>
</security>
</system.webServer>
+3
source to share
1 answer
The maxAllowedContentLength property is in bytes:
<requestLimits maxAllowedContentLength= "10485760"/>
10485760 bytes = 10 MB. Therefore, if you try to download a file larger than 10 MB, you will fail.
Keep up to date in between maxRequestLength
, which is in KB:
<system.web>
<!-- Limit file uploads to 55MB -->
<httpRuntime maxRequestLength="56320" executionTimeout="1500"/>
</system.web>
which indicates a 55MB limit and yours requestLimits
. Like this:
<system.webServer>
<security>
<requestFiltering>
<!-- Limit file uploads to 55MB -->
<requestLimits maxAllowedContentLength="57671680"/>
</requestFiltering>
</security>
</system.webServer>
+9
source to share