I have an ActionResult that returns a FileContentResult that is working fine.
public ActionResult TrainingHours(int id)
EmployeeModel model = new EmployeeModel(id);
throw new HttpException(403, "Access Denied");
byte report = model.GetTrainingHoursReport(id);
return File(report, Constants.PdfMimeType, model.EmployeeHoursReportFileName);
byte report is returning LocalReport.Render("PDF", deviceInfo) of an rdlc.
The customer has requested a button on the page where they can get a whole bunch of these reports merged into 1 file.
public ActionResult MassTrainingHours(int employeeIds)
if (employeeIds == null)
return new EmptyResult();
List<byte> reportsList = new List<byte>();
foreach (int employeeId in employeeIds)
EmployeeModel model = new EmployeeModel(employeeId);
byte fileBytes = model.GetTrainingHoursReport(employeeId);
PdfMerger merger = new PdfMerger();
byte report = merger.MergeFiles(reportsList);
return File(report, Constants.PdfMimeType, "training_hours.pdf");
The merge files method:
public byte MergeFiles(List<byte> inputFiles)
MemoryStream outputMS = new MemoryStream();
Document document = new Document();
PdfCopy writer = new PdfCopy(document, outputMS);
PdfImportedPage page = null;
foreach (byte fileData in inputFiles)
PdfReader reader = new PdfReader(fileData);
int n = reader.NumberOfPages;
for (int i = 1; i <= n; i++)
page = writer.GetImportedPage(reader, i);
PRAcroForm form = reader.AcroForm;
if (form != null)
The problem is that no file is downloaded at all.
Everything seems to be working properly, I can step through the code all the way through returning the FileContentResult with no problems.
Anyone have any ideas as to what's wrong with the way I'm trying to do this or have a different approach to merging the files?