public ActionResult DownloadAllFiles(IEnumerable <string> UploadImageStatus) { serializer.MaxJsonLength = int.MaxValue; List <Files> zipFileVMList = new List <Files>(); List <UploadImageStatus> UploadedImagesList = new List <UploadImageStatus>(); try { if (UploadImageStatus != null && UploadImageStatus.Count() > 0) { foreach (string image in UploadImageStatus) { if (image.Length > 0 && image != "[]") { UploadedImagesList = Newtonsoft.Json.JsonConvert.DeserializeObject <List <UploadImageStatus> >(image); } } } if (UploadedImagesList != null && UploadedImagesList != null && UploadedImagesList.Count > 0) { foreach (UploadImageStatus image in UploadedImagesList) { zipFileVMList.AddRange(_ftpService.DownloadMultipleFiles(image, new FtpCredentials { FTPAddress = FTPAddress, FTPUserName = FTPUserName, FTPPassword = FTPPassword })); } ZipFileVM zipFileVM = _ftpService.DownloadZip(zipFileVMList); MemoryStream memoryStream = new MemoryStream(); zipFileVM.ZipFile.Save(memoryStream); return(File(memoryStream.ToArray(), "application/zip", zipFileVM.FileName)); } } catch (Exception ex) { LoggerService.LogException(ex); return(Content("Error while retrieving file")); } return(Redirect(Request["URL"])); }