I have a ajax request to apiurl where i am getting an PDF File. Now i want to display this file in a new window
$("#pdfurl").click(function (e) {
var Pdfurl = $(this).attr('data-href');
$.ajax({
url: "../RequestPages/PreviewPdf",
type: "GET",
data: { "pdfUrl": Pdfurl },
success: function (data) {
},
error: function (jqXHR, textStatus, errorThrown) {
}
});
})
public ActionResult PreviewPdf(string pdfUrl)
{
var web = new WebClient();
byte[] bytes = web.DownloadData(pdfUrl);
string mimeType = "application/pdf";
Response.AppendHeader("Content-Disposition", "inline; filename=" + "a.pdf");
return File(bytes, mimeType);
}`