File download from my ASP page

  • Thread starter Thread starter MW de Jager
  • Start date Start date
M

MW de Jager

Hi

I want to make a download link on my ASP page, however if I use a Hyperlink,
this just tries to open the file in the browser and does nothing if the file
is of an unknown type. If I right click the file, I can download it as
usual.

What do I do to get a button or a hyperlink to open the file download dialog
when such a link clicked?

Thanks for any help

Kind regards
MW
 
Frank made a post later today where he does what you want.

This will help you on your way :

Response.AddHeader("Content-Disposition", "attachment;filename=test.txt")


Cheers,
Tom Pester
 
You can use code something like this:

Response.Clear()
Response.ContentType = Whatever
Response.Writefile("c:\whatever.doc")
Response.AddHeader("Content-Disposition", _
"inline;filename=whatever.doc")
Response.End()

Here's more info:
http://SteveOrr.net/articles/EasyUploads.aspx
 
Thanks Steve, this works.

I did however have to change the "inline;filename=whatever.doc"
to "attachment;filename=whatever.doc"

Kind regards
MW
 
Say for instance I want to do a file download from another website, but also
link this to a button.

I tried to do this with
Response.WriteFile("http//www.myglobalsite.com/files/testfile.dat"), but the
browser complains about the URL not being a virtual directory.

Any ideas?

Kind regards
MW
 

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

Back
Top