I need to render an image returned from a controller to display it to users.
I believe that this code is very close to the final result, but I can not reach this final result, a standard image is always rendered as if it could not be displayed.
Client clicks a button that triggers this code:
$.ajax({
url: url, //(url possui quatro parametros string)
type: 'GET',
success: function (data) {
//$("#myImage").attr("src", url);
//aqui vai o código para renderizar a imagem vinda do controller.
$("#TesteLoad").html("");
loading = false;
},
error: function () {
$("#myImage").attr("src", "~/Img/Not_Avaible_620.png");
$("#TesteLoad").html("");
loading = false;
}
});
Server treats the request, fetches the image and returns:
return File(new MemoryStream(response.Map).GetBuffer(), "image/png");
I looked for a lot, but what I think is always "How to return a controller image" which is usually downloadable, but I need to render this image inside an html tag, since it will be part of the layout.
Image is not for download, it is to be displayed.