Request body too large. The max request body size is 30000000 bytes.

发布时间 2023-09-18 17:55:54作者: hofmann

调用 .Net Core 6.0 Web API 报错:Request body too large. The max request body size is 30000000 bytes.

Startup.cs增加如下内容:

            services.Configure<KestrelServerOptions>(options =>
            {
                options.Limits.MaxRequestBodySize = int.MaxValue;
            });

            services.Configure<FormOptions>(options =>
            {
                options.ValueLengthLimit = int.MaxValue;
                options.MultipartBodyLengthLimit = int.MaxValue;
            });