前端用Form表单包裹文件input,上传时传参new FormData($("#submitVideo")[0])
但是!!!后台Request.Form.Files[i]取不到文件,Form里面就已经抛了异常,一般会出现错误:
System.IO.InvalidDataException: Multipart body length limit 16384 exceeded
core默认只能传输10+k的文件?应该不是的,不过我没找着原因。
解决方法:
1. 在startup.cs的ConfigureServices方法加入:
services.Configure<FormOptions>(x =>
{ x.ValueLengthLimit = int.MaxValue; x.MultipartBodyLengthLimit = int.MaxValue; // In case of multipart });
2. 在被调用方法添加入参
[HttpPost]
public ActionResult UploadOther(IFormCollection files)