默認上傳文件大小不超過30M
第一個問題:
IIS 10.0 詳細錯誤 - 404.13 - Not Found
請求篩選模塊被配置為拒絕超過請求內容長度的請求。
服務器上的請求篩選被配置為拒絕該請求,因為內容長度超過配置的值。
解決方案:在發布的項目文件夾下面打開webconfig文件,在標簽<system.webServer>中加入
<security> <requestFiltering > <requestLimits maxAllowedContentLength="2147483647" ></requestLimits> </requestFiltering> </security>
這種方法之后最大上傳到128M
第二個問題:
An unhandled exception occurred while processing the request.
InvalidDataException: Multipart body length limit 134217728 exceeded
解決方案:在startup的ConfigureServices方法中做如下處理:
services.AddMvc(); // 解決Multipart body length limit 134217728 exceeded services.Configure<FormOptions>(x => { x.ValueLengthLimit = 2147483647; x.MultipartBodyLengthLimit = 2147483647; //2G });