MVC中的大文件上传问题

时间:2014-06-21 17:16:37

标签: asp.net-mvc file-upload asp.net-mvc-5

我有一个上传文件的异步方法。在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>

1 个答案:

答案 0 :(得分:0)

我解决了我的问题。这是来自主机小组的enabling 32 bit applications