Response.CacheControl = "no-cache"; Response.AddHeader("Pragma", "no-cache");
Response.Expires = -1;
byte[] data = // Load from DB // Clear the any response already buffered (just in case) Response.ClearContent(); Response.ClearHeaders(); // Set Buffering ON Response.Buffer = true; // Prevent this page from being cached. // NOTE: we cannot use the CacheControl property, or set the PRAGMA header value due to a flaw re: PDF/SSL/IE Response.Expires = -1; // Set the ContentType Response.ContentType = "application/pdf"; // Specify the number of bytes to be sent Response.AddHeader("Accept-Header", data.Length.ToString()); // Write the file to the stream Response.BinaryWrite(data); // Wrap it up Response.Flush(); Response.Close(); Response.End();