Download links

  • Thread starter Thread starter Ron
  • Start date Start date
R

Ron

Hi all,

Probably a simple question... How can I make a link or a button
download a file instead of just opening it? Thanks.
 
(e-mail address removed) (Ron) wrote in
Probably a simple question... How can I make a link or a button
download a file instead of just opening it?

You need to change the Response.ContentType to an unknown content type.
 
Steve said:
Response.ContentType = "application/PDF";
Response.AppendHeader("content-disposition", "attachment:
filename=test.pdf");
Response.WriteFile("c:\test.pdf");

Here's more info:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref
/html/frlrfsystemwebhttpresponseclasswritefiletopic.asp
http://searchvb.techtarget.com/vsnetTip/1,293823,sid8_gci937876_tax293
033,00.html
http://www.aspnetpro.com/NewsletterArticle/2003/09/asp200309so_l/asp20
0309so_l.asp

The WriteFile needs a MapPath:

Response.WriteFile(Server.MapPath(@"c:\test.pdf"));

Eric
 
Eric said:
The WriteFile needs a MapPath:

Response.WriteFile(Server.MapPath(@"c:\test.pdf"));

Eric

Sorry, I guess it doesn't need MapPath if you specify a full pathname.

Eric
 
Back
Top