Using Hyperlink Control for file download

R

rh

Hi,

I am using a Hyperlink control that links to an Excel file. I would like
the "File Download" dialog box to appear instead of the Excel file
automatically opening within the browser.

What do I need to do? Thanks in advance.
 
W

Winista

Instead of providing direct link to XLS file, let the link goto an ASP.Net
page. On that page, read your XLS file from file system and stream it to the
response stream. And set content-type header of response to "octet-stream".
That should do it.

Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment;
filename=myexcelfile.xls");
Response.WriteFile(fileObject);
Response.End();
 

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

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top