2014-10-30 39 views
-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

+1

你是什么意思_cant catch the error_。你已经发现了错误,并在'catch'块中添加了消息并返回了视图来显示它! – 2014-10-30 20:22:24

回答

1

其实你正赶上错误! 这就是为什么您的错误信息"Unable to save changes. Try again, and if the problem persists see your system administrator."会在浏览器中正常显示并且没有运行时错误说明发生了异常。

相关问题