4
I have a question as to a possible improvement in the method when an error occurs in a Action
and redirect to an error page. At the moment, I do so on Action
:
public ActionResult Index()
{
try
{
//Um código qualquer aqui
return View();
}
catch (Exception ex)
{
return RedirectToAction("Index", "Erro");
}
}
That is, in case of a code error I redirect to the Action Index
of Controller Erro
. It turns out, this method I use has a problem. When the View
that I will return is inside a Modal
, the error page is kind of displayed inside the Modal
, getting the layout totally disfigured.
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.
As you are calling the Modal, could add this part?
– Randrade