Download PDF file using code


string str_FilePath = Server.MapPath("UploadedFiles/test.pdf");
System.IO.StreamReader sr = new System.IO.StreamReader(str_FilePath);
Response.BufferOutput = true;
Response.AppendHeader("content-disposition", "attachment; filename=test.pdf");
Response.ContentType = "application/pdf";
Response.TransmitFile(str_FilePath);

Copy and paste the above code in button_click event. When you will click the button test.pdf will be downloaded.

Comments