Has anyone been able to force download a PDF for example and how is it best to get the full file path?
var link = Model.Value<Link>("pathToPDFFile");
//var filePath = @link.Url;
var filePath = Request.PhysicalApplicationPath + @link.Url;
Response.AddHeader("Content-Type", "application/pdf");
// Set the filename and attachment disposition
Response.AddHeader("content-disposition", "attachment;filename=" + (filePath));
Response.Write(filePath);
// End the response
Response.End();
Force Download PDF hosted on umbraco cloud
Has anyone been able to force download a PDF for example and how is it best to get the full file path?
Add the download attribute to the anchor tag
<a href="/path/to/your/receipt.pdf" download>Download Receipt</a>
is working on a reply...