赞
踩
点击查看详细报错信息:
Request body too large. The max request body size is 30000000 bytes.
意思是超出了body的最大限制30M。
net出于安全考虑,对body的大小做了限制,超出了限制就会form转化失败,导致我们Reuest.Form为空,最终抛出异常,解决办法也很简单,主要从以下三个方面对症下药:
The default request limit (maxAllowedContentLength) is 30,000,000 bytes, which is approximately 28.6MB. Customize the limit in the web.config file:
- <system.webServer>
- <security>
- <requestFiltering>
- <!-- Handle requests up to 1 GB -->
- <requestLimits maxAllowedContentLength="1073741824" />
- </requestFiltering>
- </security>
- </system.webServer>
Note: Without this application running on IIS would not work.
- services.Configure<IISServerOptions>(options =>
- {
- options.MaxRequestBodySize = int.MaxValue;
- });
- services.Configure<KestrelServerOptions>(options =>
- {
- options.Limits.MaxRequestBodySize = int.MaxValue; // if don't set default value is: 30 MB
- });
- services.Configure<FormOptions>(x =>
- {
- x.ValueLengthLimit = int.MaxValue;
- x.MultipartBodyLengthLimit = int.MaxValue; // if don't set default value is: 128 MB
- x.MultipartHeadersLengthLimit = int.MaxValue;
- });
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。