【发布时间】:2019-03-13 03:55:51
【问题描述】:
我有一个 android 客户端和 asp.net 服务器,我正在使用 web api 2。 我想将图像从服务器返回到客户端作为响应的一部分,我的意思是如果我的响应对象是:
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public string Category { get; set; }
public decimal Price { get; set; }
}
现在我希望我的对象看起来像:
public class Product
{
public int Id { get; set; }
public string Name { get; set; }
public string Category { get; set; }
public decimal Price { get; set; }
public string Image { get; set; }
}
因此string Image 是来自服务器解决方案中包含图像的文件夹中的图像。
我该怎么做?
(我不知道如何定义图像对象,所以我将其定义为字符串)
【问题讨论】:
-
我希望图像成为响应的一部分,这样我将返回我的 Product 对象而不是 HttpResponseMessage 对象
-
你想要实际的图像,还是只需要它在磁盘上的路径?
-
@Stuart 实际图片