Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing info to another action using RedirectToAction - MVC
    primarykey
    data
    text
    <p>I have this action:</p> <pre><code> public ActionResult Report(AdminReportRequest reportRequest, FormCollection formVariables) { AdminEngine re = new AdminEngine(); AdminReport report = re.GetCompleteAdminReport(reportRequest); return View(report); } </code></pre> <p>I was wondering how could I go about Redirecting to another action within the same controller, passing the AdminReportRequest, and FormCollection variables?</p> <p>I had something like this in mind:</p> <pre><code> 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" }; } </code></pre> <p>This is obviously wrong and throws up some errors, such as:</p> <blockquote> <p>'System.Web.Mvc.Controller.RedirectToAction(string, string, System.Web.Routing.RouteValueDictionary)' has some invalid arguments</p> </blockquote> <p>and</p> <blockquote> <p>Argument 3: cannot convert from 'System.Web.Mvc.FormCollection' to 'System.Web.Routing.RouteValueDictionary'</p> </blockquote> <p>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.</p> <p>thanks.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload