I am implementing the exception handling in an ASP.NET MVC 5 application, and I have chosen to use HandleErrorAttribute, here the code that implements
[HandleError(ExceptionType = typeof(DbUpdateException), View = "Error")]
public class CompaniaController : Controller
{
private CompaniaRepository companiaRepository = null;
public CompaniaController()
{
this.companiaRepository = new CompaniaRepository(new InventarioContext());
}
public ActionResult Listar()
{
var companias = companiaRepository.Listar().ToList();
List<Moneda> monedas = monedaRepository.Listar().ToList();
ViewBag.Monedas = new SelectList(monedas, "MonedaID", "Descripcion");
return View( "Listar", companias);
}
}
I also add the configuration of web.config
<customErrors mode="On"></customErrors>
Executing the application in debug mode, I see that it first falls down, and after giving it F5 the view with the error message appears. To what do I owe that ?, or what part do I need to configure so that the error view is the one that appears and the application does not fall?
I appreciate your time.