597 characters | 19 lines | 597 Bytes
DOWNLOAD | RAW | EMBED | CREATE NEW VERSION OF THIS PASTE | REPORT ABUSE | x
  1. /// <summary>
  2. /// Sends the given file within response
  3. /// </summary>
  4. /// <param name="file">File to send</param>
  5. protected void SendFile(CMSOutputFile file)
  6. {
  7.     // Clear response.
  8.     Response.Cookies.Clear();
  9.     Response.Clear();
  10.  
  11.     Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
  12.  
  13.     if ((file != null) && file.IsValid)
  14.     {
  15.         if (file.MimType == "application/pdf")
  16.         {
  17.              // file is a PDF -- force it to download ("save as")
  18.              Response.AddHeader("Content-Disposition", "attachment; filename" + file.Attachment.AttachmentName);
  19.         }