导出的CSV下载卡在Firefox中

时间:2010-09-24 17:04:45

标签: c# csv

我正在使用以下代码将CSV导出到Firefox:

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();

然而,firefox在下载文件时陷入“启动”状态,我的猜测是firefox一直在等待接收更多字节,这只发生在firefox中,IE工作正常,我错过了标题还是你看错了什么用代码?

1 个答案:

答案 0 :(得分:1)

而是使用TransmitFile

  

直接将指定文件写入   没有的HTTP响应输出流   在记忆中缓冲它。