本文介绍了IFormFile在ASP.NET Core 2.1中始终返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Api方法如下所示
[HttpPost] public async Task<BaseListResponse<MediaStorageModel>> MediaBrand(IFormFile file, int brandId) { var files = new List<IFormFile>(); files.Add(file); var response = await this.Upload(files, "brand", brandId); return response; }我的邮递员配置
将我的dotnet核心从2.0升级到2.1不能正常工作,任何人都可以提供帮助. 出了什么问题
Upgrade my dotnet core from 2.0 to 2.1 thie become not working, can anyone help about this. What going wrong
推荐答案我遇到了同样的问题,我可以通过将'Name'命名参数应用于FromForm属性中具有File字段名称的FromForm属性来解决此问题.形式.它指定表单中的哪个字段绑定到method参数.更改您的方法签名,如下所示.
I've faced the same issue, I was able to fix it by applying the 'Name' named parameter to FromForm attribute with name of the File field in the form. It specifies which field in the form to bind to the method parameter. Change your method signature as shown here.
[HttpPost("status")] public async Task<BaseListResponse<MediaStorageModel>> MediaBrand([FromForm(Name ="file")] IFormFile file, int brandId)更多推荐
IFormFile在ASP.NET Core 2.1中始终返回null
发布评论