Esempio n. 1
0
        public ActionResult DownloadFile(Guid fileGuid, string fileName)
        {
            try
            {
                var path = ExcelExportHelper.GetFilePath(fileGuid, _fileStoragePath);
                if (!System.IO.File.Exists(path))
                {
                    _logger.Error(Constants.FileNotFoundMessage);
                    return(Redirect(NotFoundPageUrl));
                }

                var bytes = System.IO.File.ReadAllBytes(path);
                return(File(bytes, "application/vnd.ms-excel", fileName));
            }
            catch (Exception ex)
            {
                _logger.Error(Constants.FailedToDownloadFileMessage, ex);
                return(Redirect(ErrorPageUrl));
            }
        }