Fra*_*ons 3 c# asp.net-mvc amazon-ec2 asp.net-mvc-3
我需要一种在我的.net mvc3网站(托管在亚马逊上)上传大文件(50+ MB)的方法.尝试上传大型zip文件(36.9MB)后,FireFox显示"连接已重置"屏幕,FireBug在状态下显示"已中止".
关于如何解决它的任何想法?
控制器:
private void SaveFile(HttpPostedFileBase uploadedFile)
{
using (var file = System.IO.File.Create(Server.MapPath("/uploads/" + uploadedFile.FileName))
uploadedFile.InputStream.CopyTo(file);
}
Run Code Online (Sandbox Code Playgroud)
Web.config文件:
<system.web>
<httpRuntime maxRequestLength="56320" executionTimeout="1500"/>
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength= "10485760"/>
</requestFiltering>
</security>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
Dar*_*rov 10
该maxAllowedContentLength属性是以字节为单位:
<requestLimits maxAllowedContentLength= "10485760"/>
Run Code Online (Sandbox Code Playgroud)
10485760字节= 10MB.因此,如果您尝试上传大于10MB的文件,则会失败.
maxRequestLength在KB 之间保持一致:
<system.web>
<!-- Limit file uploads to 55MB -->
<httpRuntime maxRequestLength="56320" executionTimeout="1500"/>
</system.web>
Run Code Online (Sandbox Code Playgroud)
这表示限制为55MB和你的requestLimits.像这样:
<system.webServer>
<security>
<requestFiltering>
<!-- Limit file uploads to 55MB -->
<requestLimits maxAllowedContentLength="57671680"/>
</requestFiltering>
</security>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3391 次 |
| 最近记录: |