This might be a simple one but here goes:
I'm implementing an excel downloadable report in my MVC3 application. I've used this method in the past and it's worked perfectly, however in this case, there is a chance that sales data may not exist for the report. Here is my code:
I have a FileResult action within a Reports controller:
[HttpPost]
public FileResult ExcelReportDownload(ReportExcelDownloadRequest reportRequest)
{
ReportEngine re = new ReportEngine();
Stream report = re.GetReport(reportRequest);
return new FileStreamResult(report, "application/ms-excel")
{
FileDownloadName = "SalesReport.xls"
};
}
My issue is that sometimes the report stream may be null meaning that there's no sales info available, in which case I would rather redirect to a View that displays a message to say there is no sales information available, however I am not sure how to achieve this.
Is there a way to do this?