由于在工作中遇到了上传大型文件,出现了以下错误
|
1 |
Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException: Request body too large. |
我查询了国内很多同行给的解决方案,这些都对微服务这块没用,于是去浏览了国外的解决方案:https://stackoverflow.com/questions/51158079/microsoft-aspnetcore-server-kestrel-core-badhttprequestexception-request-body-t。里面其中一个方案:在Startup.cs中加以下代码
|
1 2 3 4 5 6 7 |
// 200 MB const int maxRequestLimit = 209715200; // If using Kestrel services.Configure<KestrelServerOptions>(options => { options.Limits.MaxRequestBodySize = maxRequestLimit; }); |
当然里面还有关于IIS和Web的解决方案,详情可以移步过去看一看
from:https://blog.csdn.net/Cool_ketchup/article/details/118489652