G
Guest
I'm using the following code to stream a CSV file download to the client
browser -
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
HttpContext.Current.Response.AddHeader( "content-disposition","attachment;
filename=" + filename );
HttpContext.Current.Response.BinaryWrite(bytes);
HttpContext.Current.Response.End();
(where <filename> is equal to the filename, eg test.csv; and <bytes> is
equal to a bytearray of the actual CSV data)
Everything is fine and dandy except for one tiny glitch - The "File
Download" dialog box (the one that asks Save, Open, Cancel, More Info)
appears twice in succession when you click on Open. If you click on Save,
the CSV file is saved ok to the clients machine then the user is prompted to
Open the file. If you simply click on Open, the same dialog box immidiately
reappers and you have to click on Open again to display the file in Excel.
browser -
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
HttpContext.Current.Response.AddHeader( "content-disposition","attachment;
filename=" + filename );
HttpContext.Current.Response.BinaryWrite(bytes);
HttpContext.Current.Response.End();
(where <filename> is equal to the filename, eg test.csv; and <bytes> is
equal to a bytearray of the actual CSV data)
Everything is fine and dandy except for one tiny glitch - The "File
Download" dialog box (the one that asks Save, Open, Cancel, More Info)
appears twice in succession when you click on Open. If you click on Save,
the CSV file is saved ok to the clients machine then the user is prompted to
Open the file. If you simply click on Open, the same dialog box immidiately
reappers and you have to click on Open again to display the file in Excel.