[转].netcore webapi post参数长度超过最大限制

https://blog.csdn.net/liwan09/article/details/89597848

问题描述:.Net Core 项目发布后,在form 表单提交保存数据时,提示 请求的长度超过最大限制

代码修改

Starpup.cs中

//配置文件大小限制
services.Configure<FormOptions>(options =>
{
options.ValueLengthLimit = int.MaxValue;
options.MultipartBodyLengthLimit = int.MaxValue;// 60000000;
options.MultipartHeadersLengthLimit = int.MaxValue;
});
Program.cs中

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseKestrel(options =>
{
//options.Limits.MaxRequestBufferSize = 302768;
//options.Limits.MaxRequestLineSize = 302768;
options.Limits.MaxRequestBodySize = int.MaxValue;//限制请求长度
})
.UseUrls("http://*:1802")
.UseStartup<Startup>();

 

 

作者:xuejianxiyang
出处:http://xuejianxiyang.cnblogs.com
关于作者:Heaven helps those who help themselves.
本文版权归原作者和博客园共有,欢迎转载,但未经原作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

原文地址:https://www.cnblogs.com/xuejianxiyang/p/15744586.html