private void DownloadPdfReport(int responseId) { try { var db = new AssessmentRepo(); var model = db.GetAnswers(QuestionCache.AssessmentName, _cultureName, responseId); var scoringModel = new ScoringModel(); var report = scoringModel.GetReport(model); using (var ms = new System.IO.MemoryStream()) { // create report var pdf = new PdfReport(); pdf.GenerateReport(report, ms, null); // Send response to browser Response.Clear(); Response.Cache.SetCacheability(HttpCacheability.NoCache); //HttpContext.Current.Response.ContentType = "pdf/application"; // Causes the pdf file to download rather than display in browser Response.ContentType = "application/pdf"; // Causes the pdf file to display directly in browser Response.AddHeader("content-disposition", "inline;filename=\"" + SmtpMail.ReportFilename + "\""); // Filename is required if downloading rather than displaying pdf Response.OutputStream.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length); Response.Flush(); Response.End(); Response.Close(); } } catch (Exception e) { Logger.Log(LogLevel.Error, e.Message); } }