How to open files automatically after download?

A

ad

I used the codes below to send a Excel file form Web Server to client.
The file is save to client's disk after download.
How can I open the file automatically after saving it?



//////////////////////////////////////////////////////////////////////////////////////////////////////////////
MemoryStream sm= new MemoryStream();
....
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment;
filename=Test.xls");
Response.AddHeader("Content-Length", ms.Length.ToString());
Response.ContentType = "application/excel"; //octet-stream";
Response.BinaryWrite(ms.GetBuffer());
Response.End();
 
M

Marina Levit [MVP]

As far as I know, this is a client side setting, for whether or not the user
wants to open all files of a certain type, or still get the prompt whether
or not to save.

As an aside, this is really an ASP.NET question, and so belongs in that
newsgroup.
 
J

John Fullmer

In xp the default for Microsoft friendly extensions is to try to open
the file. You actually have to turn it off in Internet Explorer >
"Advanced" tab.

Other than that you are going to have to write a client control.

- John Fullmer
 
C

Chris Chilvers

I used the codes below to send a Excel file form Web Server to client.
The file is save to client's disk after download.
How can I open the file automatically after saving it?



//////////////////////////////////////////////////////////////////////////////////////////////////////////////
MemoryStream sm= new MemoryStream();
....
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment;
filename=Test.xls");
Response.AddHeader("Content-Length", ms.Length.ToString());
Response.ContentType = "application/excel"; //octet-stream";
Response.BinaryWrite(ms.GetBuffer());
Response.End();

You could try changing Content-Disposition to inline, the browser will
then try to display it if it can. But I've found trying to view office
documents (especially powerpoint presentations) less than optimal. Also
if you have any sort of authentication that requires cookies and the
users are using older versions of office (might be xp) they will need to
have updated it otherwise it will not send the cookies to sever when it
tries to open it (when set to inline the office application will
download the file, not internet explorer).

Local user settings, etc. may still choose to ignore the inline and
offer to download it anyway.
 
G

Guest

I am saving more than 1 excel file on the server.How can I open all the files
automatically after saving it? ( one by one) on a single button click
 
J

Jeff Dillon

You can't. Unless you use an ActiveX control, which has already been stated

Jeff
 

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

Top