NetCore 3.1 大文件上传报错--413 Payload Too Large
十年河东,十年河西,莫欺少年穷
学无止境。,精益求精
1、报错信息如下:
Request URL: https://xx.com/webapi/api/ad_video/Upload Request Method: POST Status Code: 413 Payload Too Large Remote Address: 106.15.105.219:443 Referrer Policy: strict-origin-when-cross-origin
2、解决方案如下:
在web.config 中 <system.webServer> 节下增加如下配置
<security> <requestFiltering> <requestLimits maxAllowedContentLength="314572800" /> </requestFiltering> </security>
最大支持上传 300MB
注意:每次发布,都需要重新添加,或者选择不替换 web.config
3、startUp中 ConfigureServices(IServiceCollection services) 增加如下配置
services.Configure<IISServerOptions>(options => { options.MaxRequestBodySize = 314572800; });
参考:https://stackoverflow.com/questions/51158079/microsoft-aspnetcore-server-kestrel-core-badhttprequestexception-request-body-t