Home All Groups Group Topic Archive Search About

How to open files automatically after download?

Author
27 Apr 2006 11:56 AM
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();

Author
27 Apr 2006 3:17 PM
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.

Show quote
"ad" <fly***@wfes.tcc.edu.tw> wrote in message
news:O7hcuGfaGHA.3408@TK2MSFTNGP04.phx.gbl...
>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();
>
Author
27 Apr 2006 4:11 PM
Jeff Dillon
You can't. Unless you install a client-side ActiveX control

Jeff

Show quote
"ad" <fly***@wfes.tcc.edu.tw> wrote in message
news:O7hcuGfaGHA.3408@TK2MSFTNGP04.phx.gbl...
>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();
>
Author
27 Apr 2006 5:07 PM
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
Author
30 Apr 2006 1:04 AM
Chris Chilvers
Show quote
On Thu, 27 Apr 2006 19:56:45 +0800, "ad" <fly***@wfes.tcc.edu.tw> wrote:

>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.
Author
17 May 2006 3:03 PM
Gajender Pal
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


Show quote
"ad" wrote:

> 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();
>
>
>
Author
17 May 2006 7:07 PM
Jeff Dillon
You can't. Unless you use an ActiveX control, which has already been stated

Jeff

Show quote
"Gajender Pal" <Gajender P**@discussions.microsoft.com> wrote in message
news:8711E46A-12F5-4BEA-A798-9D941052E4FE@microsoft.com...
>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
>
>
> "ad" wrote:
>
>> 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();
>>
>>
>>

AddThis Social Bookmark Button