0

I am passing search string from Search action to detail action but on being received in detail action it turns out to be null.

I am using MVC3 and .NET framework 4.0:

public ActionResult Search(string search)
{
    if (string.IsNullOrEmpty(search))
        return RedirectToAction("Index");

    return RedirectToAction("Details", "Invoice", search = search.Trim());
}

public ActionResult Details(string id)
{
    if (string.IsNullOrEmpty(id))
        return RedirectToAction("Index");

    ObjectParameter[] parameters = new ObjectParameter[3];
    parameters[0] = new ObjectParameter("CUSTNMBR", id);
    parameters[1] = new ObjectParameter("StartDate", System.DateTime.Now.Date.AddDays(-90));
    parameters[2] = new ObjectParameter("EndDate", System.DateTime.Now.Date);

    return View(_db.ExecuteFunction<Models.Invoices>("uspGetCustomerInvoices", parameters).ToList<Models.Invoices>());
}
Martin Buberl
  • 45,844
  • 25
  • 100
  • 144
14578446
  • 1,044
  • 7
  • 30
  • 50

2 Answers2

0

You should be able to just return Details() since you are in the same controller and it returns an ActionResult.

hoserdude
  • 831
  • 1
  • 6
  • 14
0

You should use:

return RedirectToAction("Details", "Invoice", new { id = search.Trim() });
Romias
  • 13,783
  • 7
  • 56
  • 85