i have application where user can download excel report using this button:
<a href="@Url.Action("GetYearlyReport", new {@ViewBag.plantId})" class="excelIcon" title="Get Yearly Report"></a>
my method looks following:
[HttpPost]
public ActionResult GetYearlyReport(int plantId)
{
string fileName = Reports.GenerateYearlyReport();
if (!String.IsNullOrEmpty(fileName))
{
byte[] fileBytes = GetFile(fileName);
return File(fileBytes, MediaTypeNames.Application.Octet, fileName);
}
return Json(new { Result = "ERROR", Message = "Missing some parameters." });
}
Now , wheren filename isn't empty then i got the file, but when it is then i am redirected to non existed page GetYearlyReport, while I would like to just say message from json, is that possbile?