Skip to content

Instantly share code, notes, and snippets.

@TheTfactor
Created April 17, 2013 14:17
Show Gist options
  • Save TheTfactor/5404644 to your computer and use it in GitHub Desktop.
Save TheTfactor/5404644 to your computer and use it in GitHub Desktop.
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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment