i using Asp.net Core Razor Page for my Current Project ... I have a Page-Handler (Action) for send image to my page with Ajax ... I send request with ajax to my handler and my response is Suitable image to page but image dont show in my img src tag !
public IActionResult OnGetDeleteImage(ImageType imageType)
{
return File(DefaultImage(imageType), "image/png", Guid.NewGuid().ToString());
}
... DefaultImage get image path on server . and ajax request :
$.ajax({
type: 'GET',
url: deleteImagePath,
beforeSend: function (xhr) {
xhr.setRequestHeader("XSRF-TOKEN",
$('input:hidden[name="__RequestVerificationToken"]').val());
},
success: function (data) {
alert(data);
$("#" + id).attr("src",data);
},
error: function (err) {
alert(err);
}
my code return image content but dont show that in img src . thanks.
See Question&Answers more detail:os