【发布时间】:2011-09-07 18:45:44
【问题描述】:
我在尝试使用 RedirectToAction 时收到此错误,任何人都可以就为什么会发生这种情况提供任何建议,我之前使用过这个没有任何问题,我一定遗漏了一些东西。
无法将类型“System.Web.Mvc.RedirectToRouteResult”隐式转换为“System.Web.Mvc.ViewResult”
[HttpPost]
public ViewResult Edit(Customer customer)
{
if (ModelState.IsValid)
{
customersRepository.SaveCustomer(customer);
TempData["message"] = customer.CustomerName + " has been saved.";
return RedirectToAction("Index");
}
else //validation error, so redisplay the same view
return View(customer);
}
问候
利亚姆
【问题讨论】:
标签: asp.net asp.net-mvc-2 redirecttoaction