前端用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)