I am exporting a RDLC report into word file manually and download it into Downloads Folder of user's profile, but when I click the export button I split it into several files, the problem is that it downloads only the first file and ends the action
for (int i = 0; i < lsUniv.Count; i++)
{
RenderAndDownloadWord(ReportViewer_Split.LocalReport,lsUniv[i].ToString());
}
private void RenderAndDownloadWord(LocalReport report,string fileName)
{
//LocalReport report = ReportViewer_Split.LocalReport;
string mimeType, encoding, extension;
string[] streamIds;
Warning[] warnings;
byte[] bytes = report.Render("WORDOPENXML", null, out mimeType, out encoding, out extension, out streamIds, out warnings);
Response.Clear();
Response.ContentType = mimeType; // Set the MIME type for Word Open XML
Response.AddHeader("Content-Disposition", $"attachment; filename=Report_{fileName}.docx");
Response.OutputStream.Write(bytes, 0, bytes.Length);
Response.Flush();
Response.End();
}
it just download the first file and the rest won't be downloaded