I have a controller action in my mvc 4 project that gets POST request that includes files. I am posting data with XMLHttpRequest to server. When I select 10mb or smaller files to upload, upload process is successfull. But when I select 40Mb files to upload, a 404 error is occuring.
我在我的mvc 4项目中有一个控制器动作,它获取包含文件的POST请求。我将XMLHttpRequest的数据发布到服务器。当我选择要上传的10mb或更小的文件时,上传过程是成功的。但是,当我选择上传40Mb文件时,会发生404错误。
Failed to load resource: the server responded with a status of 404 (Not Found)
var formData = new window.FormData();
formData.append(this.file.name, this.file);
this.ajax = new XMLHttpRequest();
this.ajax.open("POST", "@Url.Action("FileUpload", "MyController", new { id = Model.Id })");
this.ajax.send(formData);
I put a breakpoint to my action method, small files post catched but big file requests did not come to the server, directly gives 404 error on browser console.
我给我的动作方法设置了一个断点,小文件被捕获但是大文件请求没有到达服务器,直接在浏览器控制台上给出404错误。
My action method is like this:
我的动作方法是这样的:
[HttpPost]
public ActionResult FileUpload(string id)
{
return Json("", JsonRequestBehavior.AllowGet);
}
I setted web config file limits like this.
我设置了这样的web配置文件限制。
<httpRuntime targetFramework="4.5"
maxRequestLength="2000000000"
executionTimeout="300"/>
1 个解决方案
#1
4
You can set your web config security settings like this.
您可以像这样设置Web配置安全设置。
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2000000000"/>
</requestFiltering>
</security>
#1
4
You can set your web config security settings like this.
您可以像这样设置Web配置安全设置。
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2000000000"/>
</requestFiltering>
</security>