asp.net core 上传大文件设置

1.Startup.cs中添加下面的代码

 //设置接收文件长度的最大值。
            services.Configure<FormOptions>(x =>
            {
                x.ValueLengthLimit = int.MaxValue;
                x.MultipartBodyLengthLimit = int.MaxValue;
                x.MultipartHeadersLengthLimit = int.MaxValue;
            });

2.请求的Action 加上下面的代码

RequestSizeLimit是传入一个表示字节的数字来对请求的大小进行限制,另一个DisableRequestSizeLimit的意思就是不限制了

  //[RequestSizeLimit()]
        [DisableRequestSizeLimit]
        public async Task<IActionResult> Post()
        {.......}
原文地址:https://www.cnblogs.com/yxlblogs/p/12860131.html