Skip to content

Instantly share code, notes, and snippets.

@TheTfactor
TheTfactor / PDF Display Notes.cs
Created April 17, 2013 14:17
PDF display options. Prevents autodownloading.
HttpContext.Current.Response.BufferOutput = true;
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.AddHeader("Cache-control", "no-store");
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline; filename=\"" + fileName + "\"");
HttpContext.Current.Response.ContentType = dr["MimeType"].ToString();
HttpContext.Current.Response.AddHeader("Content-Length", fileblob.Length.ToString());
HttpContext.Current.Response.BinaryWrite(fileblob);
HttpContext.Current.Response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();