code_junkie

How do you prevent downloads from being run instead of saved in IE

Nov 11th, 2011
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. HttpContext.Current.Response.Buffer = false;
  2. HttpContext.Current.Response.ClearContent();
  3. HttpContext.Current.Response.ClearHeaders();
  4. HttpContext.Current.Response.AddHeader("Content-disposition", "attachment; filename=filename.exe");
  5. HttpContext.Current.Response.AddHeader("Content-length", contentLength);
  6. HttpContext.Current.Response.AddHeader("Content-Transfer-Encoding", "binary");
  7. HttpContext.Current.Response.ContentType = "application/octet-stream";
  8. HttpContext.Current.Response.TransmitFile(filePath);
Add Comment
Please, Sign In to add comment