views:

70

answers:

2

I'm following steps of the NerdDinner tutorial. In the dinner Model class where I have error and validation handling for CRUD instead of error notifications in browser I get some kind of debugger dialog. Why is that? alt text

A: 

You will need to handle the error in the controller.

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

}
Patrik Potocki
A: 

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.

CubanX