.net core 3.1 默认不支持大文件上传 否则会 返回 413 错误

需要修改三个地方来实现大文件上传

1.Program.cs

webBuilder.UseStartup<Startup>().UseKestrel(options => {
options.Limits.MaxRequestBodySize = 1024 * 1024 * 500;
//这里最大值设置为 500M
})

2.Startup.cs

services.Configure<FormOptions>(options =>
{
options.MultipartBoundaryLengthLimit = 1024 * 1024 * 500;options.MultipartHeadersCountLimit = 10;
});

3.Controller:添加属性

[DisableRequestSizeLimit]



发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注