tags:

views:

29

answers:

1

I'm exporting a CSV to firefox using the following code:

string csv = dataTable.ToCSV();
Response.ClearContent();
Response.AddHeader("Content-disposition", "attachment;filename=solicitud.csv");
Response.AddHeader("Content-length", (Encoding.Unicode.GetBytes(csv).Length).ToString());
Response.ContentType = "application/excel";
Response.ContentEncoding = Encoding.Unicode;

Response.Write(csv);
Response.End();

However, firefox get stucked in "starting" when downloading the files, my guess is that firefox keeps waiting to receive more bytes, this only happens in firefox, IE works fine, Am I missing a header or do you see anything wrong with the code?

A: 

Instead use TransmitFile

Writes the specified file directly to an HTTP response output stream without buffering it in memory.

Adeel
I'd rather not having to write the file to disk.
ryudice