I am making an ajax call to the controller. There i am creating a pdf file.
How can i sent it to the browser so that user can download it.
[HttpPost]
public void Createpdf(string htmlpage)
{
var htmlToPdfConverter = new HtmlToPdf();
string htmlCode = "<!DOCTYPE html><html lang='en'><head><title>Report</title>/head><body>"
+ htmlpage
+ "</body></html>";
string baseUrl = null;
pdfBuffer = htmlToPdfConverter.ConvertHtmlToMemory(htmlCode, baseUrl);
System.IO.File.WriteAllBytes(@"D:\HubReport.pdf", pdfBuffer);
//System.Web.HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf");
//System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition",
// String.Format("{0}; filename=HubReport.pdf;size={1}", "attachment", pdfBuffer.Length.ToString()));
//System.Web.HttpContext.Current.Response.BinaryWrite(pdfBuffer);
//System.Web.HttpContext.Current.Response.End();
}