I have a EDIT page, and when user submits the page by entering same name, exception is raised and getting caught. But its not redirecting to edit page to display the model error instead displaying asp.net yellow error page with exception details.I still don’t have any code in controller’s OnException and I am see this on my dev machine.
try
{
//code
}
catch (Exception ex)
{
ModelState.AddModelError(string.Empty, "Customer with same name already exists.");
}
return RedirectToAction("Edit", new {id=model.id}); <--not executing
Yahooo!! I figured out what was the issue. Actually I was doing trans.commit and when it fails, I am not doing rollback in the catch block. Thanks all for your help.