0

I am trying to return multiple files using loop from controller as it just stop after returning one file.

Is there any way to make list of type FileResult add all in that list first than return it some how individually or in compressed version.

my angular code to call controller is like,

window.open(utilitiesService.getFullPath() + '/Survey/establishmentAllRecord?Id='+1020  );

This code open new window call controller method,

public FileResult establishmentAllRecord(int VisitId)
{
var result = GetRecord(VisitId);
foreach (var oParam in result)
{
int VisitId = Convert.ToInt32(oParam.Id);
FileResult res = PrintReport(VisitId);    
}
return res;
}

Here i am getting multiple records from GetRecord and than passing ID from all those records in foreach loop to "PrintReport" method that return me file and i can get it in my browser as docx file.

Issue is that it return only first file i want it to create print of all records return from GetRecord.

My res variable have three things in it,

ContentType="application/octet-stream" 
FileContent in {Bytes[854695]}
FileDownloadName = "Report1"

I am looking around if we can download then individually or all in one compressed file.

Hopes for your suggestions thanks

Doc
  • 179
  • 1
  • 11
  • 1
    I think downloading multiple files might not be possible. You may consider using some sort of archiving and download the archive. Do consult this question as well https://stackoverflow.com/questions/1041542/how-to-download-multiple-files-with-one-http-request?answertab=active#tab-top – Tayyab Apr 03 '19 at 08:17
  • Possible duplicate of [How to download multiple files with one HTTP request?](https://stackoverflow.com/questions/1041542/how-to-download-multiple-files-with-one-http-request) – Tayyab Apr 03 '19 at 08:18
  • You have to consider that the return res only returns the last record, any wat best solution is to archive them – Babak Fakhriloo Apr 04 '19 at 12:58

0 Answers0