C# 上传文件过大引起的报错

操作环境

Asp .Net Core 5.0

错误日志

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

解决方法

参照 https://www.cnblogs.com/zhang-wenbin/p/10412442.html

修改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;
	});
}
posted @ 2021-10-25 09:16  林一怂儿  阅读(991)  评论(0编辑  收藏  举报