Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to give a facility to download a pdf file when the client clicks on download link button. How do I do that?
Posted
Updated 3-Oct-10 22:54pm
v2

1 solution

Try this:

MIDL
string Filename= MapPath("document.pdf");
// This is an important header part that informs the client to download this file.
Response.AppendHeader("content-disposition", "attachment; filename=" + Path.GetFileName(Filename))
Response.ContentType = "Application/pdf"
//Write the file directly to the HTTP content output stream.
Response.WriteFile(Filename);


Good luck!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900