I am returning FilestreamResult from controller I tried both way jquery and ajax but cant succeed for download pdf/xlsx file from controller.
Controller:
var filestream = new FileStream(pdfoutputpath + ".pdf", FileMode.Open);
return new FileStreamResult(filestream, "application/pdf");
View code using jquery:
function downloadpdffile(id) {
$(".popup-overlay, .popup-content").removeClass("active");
var url = "/WorkInstructions/WorkinstructionDownload";
$.get(url, { id: id, fileformat: 2 }, function () {
});
}
using ajax:
function downloadpdffile(id) {
$(".popup-overlay, .popup-content").removeClass("active");
$.ajax({
url: "/WorkInstructions/WorkinstructionDownload",
cache: false,
type: "GET",
data: { id: id, fileformat: 2 },
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function () {
}
});