I have this action:
public ActionResult Report(AdminReportRequest reportRequest, FormCollection formVariables)
{
AdminEngine re = new AdminEngine();
AdminReport report = re.GetCompleteAdminReport(reportRequest);
return View(report);
}
I was wondering how could I go about Redirecting to another action within the same controller, passing the AdminReportRequest, and FormCollection variables?
I had something like this in mind:
public ActionResult EarningsSalesReport(AdminReportRequest reportRequest, FormCollection formVariables)
{
if (!reportRequest.Download)
{
AdminEngine re = new AdminEngine();
AdminReport report = re.GetCompleteAdminReport(reportRequest);
return View(report);
}
return RedirectToAction("ExcelSalesReport", reportRequest, formVariables);
}
public FileResult ExcelSalesReport(AdminReportRequest reportRequest, FormCollection formVariables)
{
AdminEngine re = new AdminEngine();
Stream SalesReport = re.GetExcelAdminReport(reportRequest);
return new FileStreamResult(SalesReport, "application/ms-excel")
{
FileDownloadName = "SalesReport" + DateTime.Now.ToString("MMMM d, yyy") + ".xls"
};
}
This is obviously wrong and throws up some errors, such as:
'System.Web.Mvc.Controller.RedirectToAction(string,
string,
System.Web.Routing.RouteValueDictionary)'
has some invalid arguments
and
Argument 3: cannot convert from
'System.Web.Mvc.FormCollection' to
'System.Web.Routing.RouteValueDictionary'
If someone could point me in the right direction I'd greatly appreciate it, I think I might have to edit the Global.asax file however I'm not overly familiar with this.
thanks.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…