我试过这个:
public ActionResult Index() // << it starts here
{
return RedirectToAction("ind", new { name = "aaaaaaa" });
}
[ActionName("ind")]
public ActionResult Index(string name)// here, name is 'aaaaaaa'
{
return View();
}
它有效..
所以,我试过这个:
[HttpPost]
public ActionResult Search(string cnpj) // starts here
{
List<Client> Client = db.Client // it always find one client
.Where(c => cnpj.Equals(c.Cnpj))
.ToList();
return RedirectToAction("Index", Client); // client is not null
}
public ActionResult Index(List<Client> Client) //but when goes here, client is always null
{
if (Client != null)
return View(Client);
return View(db.Client.ToList());
}
为什么会发生?第二个代码块有问题吗?