Double open dialog when downloading Excel file from ASP.NET.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to stream download an excel file from a web server. When the "Open/Save/Cancel" dialog comes up, clicking "Save" will save the file just fine. But, clicking "Open" will result in another "Open/Save/Cancel" dialog which I also have to click "Open" on. What gives with the double dialog

The download code I'm using looks like the following

Response.ClearHeaders()
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Response.AddHeader("Content-Disposition", "attachment;filename=" + sNameOnly)
Response.WriteFile(sFileName)

Note, the "sNameOnly" and "sFileName" variables are strings that are elswhere set to be the name of the file and the full (server-side) pathname, respectively

Thanks

Lowel
 
I have the same problem; at one point I thought it was because I didn't set the Content-Length
header in the response -- I never tried implementing that (since I wanted the streaming and it was
too much trouble to calculate the repsonse length), and just decided to live with it.

Scott

Lowell said:
I'm trying to stream download an excel file from a web server. When the "Open/Save/Cancel" dialog
comes up, clicking "Save" will save the file just fine. But, clicking "Open" will result in another
"Open/Save/Cancel" dialog which I also have to click "Open" on. What gives with the double dialog?
The download code I'm using looks like the following:

Response.ClearHeaders();
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
Response.AddHeader("Content-Disposition", "attachment;filename=" + sNameOnly);
Response.WriteFile(sFileName);

Note, the "sNameOnly" and "sFileName" variables are strings that are elswhere set to be the name
of the file and the full (server-side) pathname, respectively.
 
That didn't work for me. I'm still getting the same thing. I'm also occasionally getting a "Server Application Unavailable" error (this predates the code change, BTW). The excel file is generated correctly (I can see it sitting on the server), but it doesn't download. When I get the error, two log files are generated into my "TEMP" directory, both of which contain

=== Verbose logging started: 3/26/2004 16:59:49 Build type: SHIP UNICODE 2.00.2600.1183 Calling process: E:\Program Files\Microsoft Office\Office10\EXCEL.EXE ==
MSI (c) (74:14): Resetting cached policy value
MSI (c) (74:14): Machine policy value 'Debug' is
MSI (c) (74:14): ******* RunEngine
******* Product: {90280409-6000-11D3-8CFE-0050048383C9
******* Action:
******* CommandLine: *********
MSI (c) (74:14): Client-side and UI is none or basic: Running entire install on the server
MSI (c) (74:14): Grabbed execution mutex
MSI (c) (74:14): Failed to connect to server. Error: 0x8007000

MSI (c) (74:14): Failed to connect to server
MSI (c) (74:14): MainEngineThread is returning 160
=== Verbose logging stopped: 3/26/2004 16:59:49 ==


In case I'm doing something wrong, the current code is

System.IO.FileInfo fi = new System.IO.FileInfo(sFileName)
String sFileLength = fi.Length.ToString()
Response.ClearHeaders()
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Response.AddHeader("Content-Disposition", "attachment;filename=" + sNameOnly)
Response.AddHeader("Content-Length", sFileLength)
Response.WriteFile(sFileName)

Thanks

Lowel
----- Scott wrote: ----

I have the same problem; at one point I thought it was because I didn't set the Content-Lengt
header in the response -- I never tried implementing that (since I wanted the streaming and it wa
too much trouble to calculate the repsonse length), and just decided to live with it

Scot

Lowell said:
I'm trying to stream download an excel file from a web server. When the "Open/Save/Cancel" dialo
comes up, clicking "Save" will save the file just fine. But, clicking "Open" will result in anothe
"Open/Save/Cancel" dialog which I also have to click "Open" on. What gives with the double dialog
 
I'm not sure what to make of that error; I also implemented the content-length -- still doesn't
work. I tried it in Firefox and it works correctly; perhaps that an indication that IE is having a
problem invoking Excel (and it's not necessarily an Excel problem). I also tried various other
formats (like CSV) and I still get two dialogs...

I remember trying a zillion things a year ago when we implemented Excel downloads and never got
anything to work.... I hope you have better luck.

Scott

Lowell said:
That didn't work for me. I'm still getting the same thing. I'm also occasionally getting a
"Server Application Unavailable" error (this predates the code change, BTW). The excel file is
generated correctly (I can see it sitting on the server), but it doesn't download. When I get the
error, two log files are generated into my "TEMP" directory, both of which contain:
=== Verbose logging started: 3/26/2004 16:59:49 Build type: SHIP UNICODE 2.00.2600.1183 Calling
process: E:\Program Files\Microsoft Office\Office10\EXCEL.EXE ===
 
Thanks Scott

I've just realized that I didn't use the correct alias. So I'm trying again to see if I can get a response from MS

Lowell
 
Back
Top