function downloadpdForSalary() {
    $(".loader").show();
    $.ajax({
        type: 'POST',
        cache: false,
        data: $('#FormHeader').serialize(),
        url: "/SalarySheet/ExportSalarySheetTopdf",
        success: function (response) {
            $(".loader").hide();
            if (response.CommandStatus == "1") {
                window.location = '/Runreport/DownloadPdf?fileGuid=' + response.Width + '&filename=' + response.Height;
                showAndDismissAlert("success", "Downloaded Successfully");
            }
            else {
                showAndDismissAlert("error", response.CommandMessage);
            }
        },
        error: function (e) {
        }
    });
}
this is controllercode
[HttpPost] public ActionResult ExportSalarySheetTopdf(SalarySheetModel model) { var res = new JsonResponse(); try { if (model.BranchNameStr != null) model.BranchCode = string.Join(",", model.BranchNameStr); model.UserCode = UserCode; model.SessionId = SessionId; model.MenuCode = ResourceFile.LovResource.SalarySheet; var result = voucherSalaryBusiness.ExportSalarySheetToExcel(model); if (result.CommandStatus == "1") { DataTable dt = (DataTable)(JsonConvert.DeserializeObject(result.DataTableStr, (typeof(DataTable)))); XLWorkbook workbook = new XLWorkbook(); string handle = Guid.NewGuid().ToString(); workbook.Worksheets.Add(dt); using (MemoryStream memoryStream = new MemoryStream()) { workbook.SaveAs(memoryStream); memoryStream.Position = 0; TempData[handle] = memoryStream.ToArray(); } res.Width = handle; res.Height = "Salary Sheet.pdf"; res.PageName = "ExportToPdf";
            }
            res.CommandStatus = result.CommandStatus;
            res.CommandMessage = result.CommandMessage;
        }
        catch (Exception ex)
        {
            res.CommandStatus = "-1";
            res.CommandStatus = ex.Message;
        }
        var jsonResult = Json(res, JsonRequestBehavior.AllowGet);
        jsonResult.MaxJsonLength = int.MaxValue;
        return jsonResult;
    }
For Download PDf
[HttpGet] public virtual ActionResult DownloadPdf(string fileGuid, string fileName) { if (TempData[fileGuid] != null) { byte[] data = TempData[fileGuid] as byte[]; return File(data, "application/pdf", fileName); } else { return new EmptyResult(); } }