操作环境

Asp .Net Core 5.0

错误日志

Failed to read the request form. Request body too large.

解决方法

修改​​Startup.cs​​文件

public void ConfigureServices(IServiceCollection services)
{

services.AddControllers();

services.Configure<FormOptions>(x =>
{
x.MultipartBodyLengthLimit = 1024 * 1024 * 1024;
x.ValueLengthLimit = int.MaxValue;
});
services.Configure<KestrelServerOptions>(options =>
{
options.Limits.MaxRequestBodySize = 1024 * 1024 * 1024;
});
}