我正在按照NerdDinner教程的步骤进行操作。在晚餐Model类中,我有CRUD的错误和验证处理,而不是浏览器中的错误通知,我得到一些调试器对话框。这是为什么? alt text http://img196.imageshack.us/img196/8742/capturehz.png
答案 0 :(得分:0)
您需要处理控制器中的错误。
public ActionResult Create({YourObject} object)
{
try
{
//Try to save your object.
}
catch(ApplicationException ex)
{
//Do something with the exception.
}
}
答案 1 :(得分:0)
我认为代码就在那里:
if (!isValid)
throw new ApplicationExcption(...)
您需要将其更改为仅将模型传递回View。
,而不是抛出应用程序异常ModelState对象应该具有必要的值,如果视图中有Validation消息控件,则应该看到错误消息。