-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