首页 文章

空的Request.Files在mvc 4.0和ajax上传大于4mb

提问于
浏览
0

我尝试使用ajax和progressbar实现一个简单的文件上传到我的mvc 4.0控制器与VS2013和.net Framework 4.5

按预期上传最多4MB的工作,但超过4MB不起作用!调用Controller方法但是Request.Files为空!

如果我尝试大于maxAllowedContentLength的文件,请求将按预期失败 .

这是我的代码:

客户端解决方案发现于http://www.matlus.com/html5-file-upload-with-progress/#codeListing6

服务器端解决方案自我实现:

[HttpPost]
public JsonResult Upload()
{
    var name = Request.Files[0].FileName;
    var result = new {};

    return Json(result, JsonRequestBehavior.AllowGet);
}

Web.config文件:

...
<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="2147483647" />
        </requestFiltering>
    </security>
    ...

1 回答

  • 1

    在Web配置中尝试此操作

    <system.web>
        <httpRuntime maxRequestLength="2147483647" executionTimeout="1100" />
    </system.web>
    

相关问题