I want to see the code behind if it's possible, because I need to pass the property _errorId that I get with my Try Catch to my View Index.
public class PrincipalController : Controller
{
**private int _errorId;**
public ActionResult Index()
{
ViewBag.HomeViewModel = **_errorId** ;
return View();
}
[HttpPost]
public ActionResult Index(Cadastro cadastro)
{
try
{
//something
cadastro.save();
return RedirectToAction("Index");
}
catch (Exception ex)
{
**_errorId = 1;**
return RedirectToAction("Index");
}
}
}
I have a Controller with property named _errorId, and I have a to get this value and put it into a ViewBag, when my try catch returns same error, I put my property _errorId inside my Post Methods and them, when I get the error number I set my _errorId with this error's number, and them I need put this number in my ViewBag in Index();