Я пытаюсь получить pdf-байтовые данные из базы данных и показывать их как всплывающее окно
Частичное представление
<iframe id="PdfDisplay" style="width:100%;height:80vh" onload=""></iframe>
действие контроллера
public ActionResult PDFDisplay(int id)
{
byte[] pdfByte = db.MasterCopyAPIs.Where(w => w.Id == id).Select(w => w.mastercopy).FirstOrDefault();
//System.IO.File.WriteAllBytes(Server.MapPath(@"~/Files/" + TempData["fileName"].ToString()),pdfByte);
return File(pdfByte, "application/pdf");
}
вызов ajax
function DisplayMaster(id) {
$.ajax({
url: '@Url.Action("PDFDisplay", "ProductAPI")/?id=' + id,
type: 'POST',
cache: false,
success: function (data, status, txt) {
alert(data);
$("#PdfDisplay").val(data);
setTimeout(function () {
window.location.replace('@Url.Action("Index", "ProductAPI")');//Need To Specify which window to redirect
return true;
});
}
});
}
мой вид вызова
<a href="" onclick="DisplayMaster(@Model.Id)">@Model.Mastercopyname</a>