using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace Consulenza.Web { public partial class Report : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { var myPdf = (byte[])Session["pdf"]; try { // Opreazioni del client Response.Clear(); Response.ContentType = "application/pdf"; Response.AddHeader("content-length", myPdf.Length.ToString()); Response.AddHeader("Content-Disposition", "Attachment;filename=Report.pdf"); Response.BinaryWrite(myPdf); Response.Buffer = true; Response.Flush(); Response.OutputStream.Close(); Session["pdf"] = null; } catch { Session["pdf"] = null; Response.Redirect("Default.aspx", false); } } } }