【发布时间】:2014-08-12 04:45:36
【问题描述】:
我有一个异步上传文件的方法。在我的web.config 中,我已经设置了maxcontentlength。
但我无法上传大于 15mb 的文件。它给了我一个错误err_connection_reset。
我的主机还支持最大 1gb 文件上传和 90 秒执行超时。
这是我的代码示例。
[NoAsyncTimeout]
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Create(Videos video)
{
if (ModelState.IsValid)
{
if (video.CategoryId > 0)
{
if (Request.Files.Count > 0)
{
try
{
//Server.ScriptTimeout = 9001;
file.SaveAs(path);
// ... other operations
}
catch (Exception ex)
{
string error = ex.Message;
}
}
}
}
}
这是我的web.config 属性。我还尝试设置最大执行超时。
<httpRuntime targetFramework="4.5" maxRequestLength="1073741824" requestValidationMode="2.0" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" />
</requestFiltering>
</security>
【问题讨论】:
标签: asp.net-mvc file-upload asp.net-mvc-5