IFormFile在ASP.NET Core 2.1中始终返回null

编程入门 行业动态 更新时间:2024-10-26 07:26:02
本文介绍了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

本文发布于:2023-11-15 23:18:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598843.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:NET   ASP   IFormFile   null   Core

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!