private void SendCSV(int ID) { var vouchers = new Voucher().GetList(ID); var parent = vouchers.First(v => v.ID == ID); Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.AddHeader("content-disposition", string.Format("attachment; filename={0}.csv", parent.Caption)); Response.ContentType = "text/csv"; Response.AddHeader("Pragma", "public"); var sb = new StringBuilder(); vouchers.Select(v => v.Caption).ToList().ForEach(s => sb.AppendLine(s)); Response.Write(sb.ToString()); Response.End(); }