-4
我正在使用contoso大學wb應用程序。但我無法捕捉到這個錯誤。無法嘗試/發現錯誤
控制器:
public ActionResult Create(Student student)
{
try
{
if (ModelState.IsValid)
{
studentService.Add(student);
studentService.Update(student);
return RedirectToAction("Index");
}
}
catch (DataException /* dex */)
{
//Log the error (uncomment dex variable name and add a line here to write a log.
ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
}
return View(student);
}
這是錯誤的圖像:
https://www.dropbox.com/s/2sw5gor3x2d1lpi/111111.jpg?dl=0
你是什麼意思_cant catch the error_。你已經發現了錯誤,並在'catch'塊中添加了消息並返回了視圖來顯示它! – 2014-10-30 20:22:24