asp.net web api返回图片至前端

时间:2022-07-24
本文章向大家介绍asp.net web api返回图片至前端,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。
 var response = Request.CreateResponse(HttpStatusCode.OK);
 response.Content = new ByteArrayContent(data);  //data为二进制图片数据
 response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png");

 return response;