Kentico - Force download of PDF
Posted by Anonymous on May Tue 29th 6:06 AM - Never Expires| View : 66Syntax: ASP
597 characters | 19 lines | 597 Bytes
- /// <summary>
- /// Sends the given file within response
- /// </summary>
- /// <param name="file">File to send</param>
- protected void SendFile(CMSOutputFile file)
- {
- // Clear response.
- Response.Cookies.Clear();
- Response.Clear();
- Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches);
- if ((file != null) && file.IsValid)
- {
- if (file.MimType == "application/pdf")
- {
- // file is a PDF -- force it to download ("save as")
- Response.AddHeader("Content-Disposition", "attachment; filename" + file.Attachment.AttachmentName);
- }
