当前位置:网站首页>In ASP.NET Core 2.0, solve the configuration problem of large file upload
In ASP.NET Core 2.0, solve the configuration problem of large file upload
2022-08-08 10:02:00 【Drinking Water Siyuan 09】
In .net core 2.0, when the uploaded file is larger than 30MB, it will report: Request filtering on the server is configured to reject the request because the content length exceeds the configured value.
The solution to this problem is as follows:
1), add the following code in Startup.cs:
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
//Configuration file size limit 1GB
services.Configure
{
options.ValueLengthLimit = 1073741824;
options.MultipartBodyLengthLimit = 1073741824;
});
//........
}
2), add the following code before the specific method:
///
/// Upload attachments
///
///
[RequestSizeLimit(1073741824)]
, string projectId, string stage_id)
{
//......
} }
3), add a web.config file to the project, the specific code is as follows:
/system.webServer>
The problems reported in the system can be solved through the above three steps: The request screening module is configured to reject requests exceeding the length of the requested content. This is asecurity function.Please do not change this feature unless you are fully aware of the scope of the change.You can configure the IIS server to reject requests with a content length greater than a specified value.This error is returned if the requested content length is greater than the configured length.Increase the content length if needed.
边栏推荐
- 技术分享 | 接口自动化测试之JSON Schema模式该如何使用?
- IR(红外遥控)基本原理
- English token preprocessing, used to process English sentences into words
- 「每周译Go」这次我们来点不一样的!--《How to Code in Go》系列上线
- 重载与重写有什么区别?
- 梯度消失和梯度爆炸问题详解
- Is it safe to buy stocks with a straight flush?Will the funds be transferred?
- VPP static mapping to realize DNAT
- 五、业务数据分析
- Web优化躬行记(6)——优化闭环实践
猜你喜欢
随机推荐
功夫再高也怕菜刀,产品经理的那些事
Feign应用及源码剖析
idea安装步骤
The entity List to excel
英文token预处理,用于将英文句子处理成单词
利用图像二维熵实现视频信号丢失检测(Signal Loss Detection)
Flutter 游戏教程之使用 Flutter 和 Flame 重现著名的 T-Rex 游戏
VPP static mapping to realize DNAT
等式变换(2015届华为校园招聘机试题第三题 )
hdu4635 Strongly connected(tarjan计算强连通通分量+缩点+思想)
各位大佬想问下, flinkcdc采集oracle我看了下延迟大概两分钟左右,想问下有啥解决方法吗
巧用Prometheus来扩展kubernetes调度器
Loadrunner的录制event为0的问题解决方法与思路
MySQL源码解析之执行计划
d实验新异常
技术分享 | 接口自动化测试之JSON Schema模式该如何使用?
HMS Core分析服务智能运营6.5.1版本上线
Dubins曲线学习笔记及相关思考
渗透测试-xss的三种类型讲解
高并发下秒杀商品,你必须知道的9个细节