I'm having a question about a possible improvement in the method when an error occurs in a Action
and redirects to an error page. I currently do this in Action
:
public ActionResult Index()
{
try
{
//Um código qualquer aqui
return View();
}
catch (Exception ex)
{
return RedirectToAction("Index", "Erro");
}
}
That is, if I give a code error I redirect to Action Index
of Controller Erro
. It turns out that this method I use has a problem. When the View
that I'm going to return is within Modal
, the error page is sort of displayed within Modal
, leaving the layout totally unconfigured .
With this, I would like to know if there is a better or more correct way than when throwing an error exception, redirect to the correct page.