asp.net core 上传大文件设置

时间:2020-05-09 22:16:52   收藏:0   阅读:184

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!