3
雖然試圖實現第二個答案previous question,我收到一個錯誤。錯誤使用MVCContrib TestHelper
我已經實現了方法,就像帖子顯示的那樣,前三個方法正常工作。第四個(HomeController_Delete_Action_Handler_Should_Redirect_If_Model_Successfully_Delete)給出了這個錯誤:在結果的Values集合中找不到名爲'controller'的參數。
如果我的代碼更改爲:
actual
.AssertActionRedirect()
.ToAction("Index");
它工作正常,但我不喜歡「魔串」在那裏,喜歡使用所使用的其他海報的拉姆達方法。
我控制器的方法是這樣的:
[HttpPost]
public ActionResult Delete(State model)
{
try
{
if(model == null)
{
return View(model);
}
_stateService.Delete(model);
return RedirectToAction("Index");
}
catch
{
return View(model);
}
}
我在做什麼錯?
自定義擴展方法。我喜歡這種選擇,並正在使用它。我不喜歡必須將控制器名稱放在RedirectToAction中,並且這個工作完美。 – John 2013-07-01 11:10:21