web api action :
byte[] bytes = System.IO.File
.ReadAllBytes(
HttpContext.Current.Server.MapPath("~/Images/orderedList1.png"));
var result_ = new HttpResponseMessage(HttpStatusCode.OK);
result_.Content = new ByteArrayContent(bytes);
result_.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png");
return result_;
You don't need to make an AJAX call to this action. Just put an
<img>
tag and point its src property to your Web API endpoint:or if you don't know the
accountId
in advance, you could construct thisimg
tag dynamically and inject it into the DOM using javascript:and the image will be added to a container that you need to have in your DOM: