0

我正在按照 NerdDinner 教程的步骤进行操作。在晚餐模型类中,我有 CRUD 的错误和验证处理,而不是浏览器中的错误通知,我得到了某种调试器对话框。这是为什么? 替代文字 http://img196.imageshack.us/img196/8742/capturehz.png

4

2 回答 2

0

您将需要处理控制器中的错误。

public ActionResult Create({YourObject} object)
{
    try
    {
     //Try to save your object.
    }
    catch(ApplicationException ex)
    {
     //Do something with the exception.
    }

}
于 2010-05-07T11:42:08.397 回答
0

I think it's right there in the code:

if (!isValid)
    throw new ApplicationExcption(...)

Instead of throwing an application exception, you need to change that to just pass the Model back to the View.

The ModelState object should have the necessary values, and if you have the Validation message controls in your views, you should see error messages.

于 2010-05-07T12:11:38.637 回答