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>();