C# Dotnet核心->;返回jpg图像的base64字符串时web api内容类型的最佳实践
我应该放什么C# Dotnet核心->;返回jpg图像的base64字符串时web api内容类型的最佳实践,c#,.net-core,webapi,C#,.net Core,Webapi,我应该放什么 我应该在响应中包含“data:image/png;base64”,还是应该在客户机上设置 我也考虑过使用 [Route("image/{fileName}")] [Produces("text/plain or what???")] public string image(string fileName) { byte[] b = fromsomewhere(); return "data:image/jpg;base
[Route("image/{fileName}")]
[Produces("text/plain or what???")]
public string image(string fileName)
{
byte[] b = fromsomewhere();
return "data:image/jpg;base64," + Convert.ToBase64String(b);
}
哪种方法更简单,也更有效,但我仍然很感兴趣base64string的内容类型应该设置为什么…这是否回答了您的问题@tvdias它不回答我应该为base64string使用哪种内容类型
public dynamic image(string fileName)
{
byte[] b = fromsomewhere();
return new FileContentResult(b, "image/jpg");
}