CSV File Download from an ASP.NET page issue

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.
 
G

Guest

I've just been trying to solve the same problem when downloading text files
to the client. However, after a couple of hours scouring the net, the
following URL discusses the same problem which appears to be a bug in certain
IE browsers.

Apparently 'longhorn' fixes this.

The article discusses the fact that this works if the method used is GET as
opposed to POST. I have still not found any documentation from Microsoft
detailing this problem - can anyone else enlighten us?

http://www.dotnet247.com/247reference/msgs/48/243943.aspx

Thanks, Claire-Louise
 

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