【发布时间】:2020-06-03 05:02:57
【问题描述】:
我想将此对象发送到服务器:
public class Product
{
public string name { get; set; }
public string description { get; set; }
public ICollection<Photo> photos { get; set; }
}
这个对象有其他对象的集合:
public class Photo
{
public string url { get; set; }
public IFormFile file { get; set; }
public string description { get; set; }
}
如何发送Product 对象及其Photo 对象集合?以及如何在Photo 对象中发送文件?(我想使用application/json 而不是form-data)
【问题讨论】:
-
你试过什么?什么不起作用?
-
我认为您可以将文件内容作为字符串发送而不是发送 IFormFile
-
预期的负载服务器端是什么?你在写服务器和客户端吗?还是只是客户?
-
@viveknuna 对图片有用吗?
-
@zaitsman 我使用表单数据,但是因为我有嵌套的 JSON 发送,所以它不能正常工作。
标签: c# json dotnet-httpclient