In MVC, We are going to get image from server and display it in client, GetImage Action in controller is as follows:
public byte[] GetImage()
{
byte[] imgByteArray=File.ReadAllBytes("Img1.jpeg");
return imgByteArray ;
}
And javascript code in client side is as follows:
$.ajax(
...
success: function (response) {
$('#imgResult')
.attr('src', 'data:image/jpeg;base64,' + response);
},
error: function (er) {
alert(er);
}
The response is received successfully but image is not displayed and src value is set to:
src="data:image/jpeg;base64,System.Byte[]"
How can resolve this issue?