参考
asp.net web api返回图片至前端 - GUOKUN - 博客园 (cnblogs.com)
后端返回
核心代码
ini
[HttpGet]
public async Task<IActionResult> GetPic()
{
MemoryStream stream;
using (FileStream fileStream = new FileStream("Image/2.png", FileMode.Open))
{
int len = (int)fileStream.Length;
byte[] buf = new byte[len];
fileStream.Read(buf, 0, len);
stream = new MemoryStream();
stream.Write(buf, 0, len);
}
return await Task.FromResult<FileResult>(File(stream.ToArray(), "image/jpeg"));
}