【发布时间】:2021-06-10 23:10:16
【问题描述】:
在角度模型中
MyClass.ts
name: string
age: number
file: File
在网页 API 中 保存(MyClassDto)
MyClassDto.cs
string name;
int age;
IFormFile file;
从 UI 中单击按钮:
MyClass 是通过
name='test'
age=10,
file=document.getElementById('fileElement').files[0]; -> for ex:'C:\fakepath\testfile.jpg"
当调用 web api 时,我得到这个错误:
api - 将 dto 对象作为参数传递的 post 方法。
保存(MyClassDto myClassDto);
不支持接口类型的IFormFile反序列化错误。
知道当 IFormFile 是两个模型中的属性时如何发送文件吗?
【问题讨论】:
标签: c# angular asp.net-web-api angular8 webapi