Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Download links

Reply
Thread Tools

Download links

 
 
Ron
Guest
Posts: n/a
 
      09-21-2004
Hi all,

Probably a simple question... How can I make a link or a button
download a file instead of just opening it? Thanks.
 
Reply With Quote
 
 
 
 
Lucas Tam
Guest
Posts: n/a
 
      09-21-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (Ron) wrote in
news:(E-Mail Removed) om:

> 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.

--
Lucas Tam ((E-Mail Removed))
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      09-21-2004
Something along these lines should do it:

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/de...efiletopic.asp
http://searchvb.techtarget.com/vsnet...293033,00.html
http://www.aspnetpro.com/NewsletterA...200309so_l.asp

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net



"Ron" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hi all,
>
> Probably a simple question... How can I make a link or a button
> download a file instead of just opening it? Thanks.



 
Reply With Quote
 
Eric
Guest
Posts: n/a
 
      09-22-2004
Steve C. Orr [MVP, MCSD] wrote:

> 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/de...ry/en-us/cpref
> /html/frlrfsystemwebhttpresponseclasswritefiletopic.asp
> http://searchvb.techtarget.com/vsnet...i937876_tax293
> 033,00.html
> http://www.aspnetpro.com/NewsletterA...0309so_l/asp20
> 0309so_l.asp


The WriteFile needs a MapPath:

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

Eric
 
Reply With Quote
 
Eric
Guest
Posts: n/a
 
      09-22-2004
Eric wrote:

> Steve C. Orr [MVP, MCSD] wrote:
>
> > 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/de...rary/en-us/cpr
> > ef /html/frlrfsystemwebhttpresponseclasswritefiletopic.asp
> > http://searchvb.techtarget.com/vsnet...gci937876_tax2
> > 93 033,00.html
> > http://www.aspnetpro.com/NewsletterA...200309so_l/asp
> > 20 0309so_l.asp

>
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FF Crashes on Links within Links Puma Firefox 10 02-17-2009 07:12 PM
Make A Shorter Link - no new links accepted, old links still work. why? Computer Support 7 01-02-2007 09:45 PM
Site Links and Physical WAN Links =?Utf-8?B?RW5mb1BhdWw=?= MCSE 2 03-22-2005 09:23 AM
Exchange Links < Western Cartoon Cards > Exchange Links www.westerncartooncards.ca HTML 2 07-12-2004 07:59 PM



Advertisments