- <requestFiltering>
- <!-- 1GB-->
- <requestLimits maxAllowedContentLength="1073741822" />
- </requestFiltering>
Startup.cs里面的ConfigureServices方法里面添加,添加位置如图:
- /** begin xiongze 2021-03-08**************/
- //上传文件大小限制Kestrel设置
- services.Configure<KestrelServerOptions>(options =>
- {
- // Set the limit to 256 MB
- options.Limits.MaxRequestBodySize = 268435456;
- });
- //上传文件大小限制IIS设置
- services.Configure<CookiePolicyOptions>(options =>
- {
- // This lambda determines whether user consent for non-essential cookies is needed for a given request.
- options.CheckConsentNeeded = context => true;
- options.MinimumSameSitePolicy = SameSiteMode.None;
- });
- //解决文件上传Multipart body length limit 134217728 exceeded
- services.Configure<FormOptions>(x =>
- {
- x.ValueLengthLimit = int.MaxValue;
- x.MultipartBodyLengthLimit = int.MaxValue;
- x.MemoryBufferThreshold = int.MaxValue;
- });
- /** end xiongze 2021-03-08**************/