How to force download?

M

Miguel Dias Moura

Hello,

in my web site i display some links to PDF files. This links are loaded from
a database.
Anyway, when i click these links the PDF files are open in the visitors
browser and in Acrobat.

How can i force the files to be downloaded when the person clicks the link?
I don't want to use zip files.

Thank You,
Miguel
 
S

Steve C. Orr [MVP, MCSD]

Use Response.Writefile to output the PDF file.
http://msdn.microsoft.com/library/d...fsystemwebhttpresponseclasswritefiletopic.asp

Then add a line of code like this:
Response.AddHeader("Content-Disposition","attachment;filename=myfile.pdf");
The "attachment" specification requests the browser to download the file
instead of opening it. But ultimately it is up to the browser and the user
to decide what they want to do with the file; you don't have 100% control of
this from the server.
 
D

Dan Brussee

The closest Ive come to controlling this behavior is to put the PDF in
a zip file. A total kludge would be to rename the file with a pdx
extenstion and prompt the user to rename the file during the save step
to a pdf extension.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top