Hi,
I have a MVC controller in which, I am converting Array of Byte into PDF and downloading in target path, even pdf file is getting downloaded in specified path, but download option is not working i.e pdf file not downloading in C:\Users\sayedab\Downloads, I feel I am missing something, kindly verify my code and help me in this regard. Thanks.
private void DownloadContract(string nid, byte[] contractByte)
{
try
{
string savePath = System.Web.HttpContext.Current.Server.MapPath(@"~/") + @"SavePath\" + nid + "_" + "REDF Contract_" +
System.DateTime.Now.ToString("ddMMyyyyhhmmss") + ".pdf";
System.IO.File.WriteAllBytes(savePath, contractByte);
}
catch (Exception ex)
{
_redfLogs.WriteError(ex);
}
}
public ActionResult PrintContract(string legalid)
{
var objApplicationInputBL = new REDF_BL();
PrintContract_Input objPrintContract_Input = objApplicationInputBL.PrintContract(legalid);
var responsePrintContract = objFinanceClient.printContract(objCredentials, objSupportContract);
//Call Contract Download method
DownloadContract(objPrintContract_Input.NID, responsePrintContract.ContractByte);
}