我正在使用contoso university wb app。但我无法发现错误。
控制器:
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);
}
这是错误的图像:
答案 0 :(得分:1)
其实你正在抓错误!
这就是为什么您的错误消息"Unable to save changes. Try again, and if the problem persists see your system administrator."
在浏览器中正常显示,并且没有运行时错误说明发生了异常。