System.IO.MemoryStream ms = new System.IO.MemoryStream(System.Text.Encoding.GetEncoding(“Shift-JIS”).GetBytes(strBuffer));
Response.AddHeader(“Content-Disposition”,”attachment;filename=total.csv”);
Response.ContentType = “application/octet-stream”;
Response.BinaryWrite(ms.ToArray());
Response.End();
MemoryStreamが、実際のデータです。
「strBuffer(string型)」にダウンロードさせるCSVデータを突っ込んでおいて、それをMemoryStreamに乗せて吐き出すといったイメージですね。
別にサーバサイドでファイル生成して、それをダウンロードさせてもいいのですが、こっちの方がファイルIOもなく、ゴミも残らないのでスマートかと思われます。