Vote count:
0
I am learning ASP.NET MVC. And I faced with problem of error handling. I know about controllers has to be thin and there is HandleErrorAttribute, but it seems to me it does not work with POST actions. For instance, I have such action method:
[HttpPost]
public ActionResult Create(MyModel model)
{
if (!ModelState.IsValid)
return View(model);
try
{
_myService.CreateModel(model);
return RedirectToAction("Details", new { id = model.Id });
}
catch (Exception ex)
{
ModelState.AddModelError("", ex.Message);
return View(model);
}
}
Is it possible make this method with elegant error handling?
asked 35 secs ago
Where to handle error in HttpPost methods?
Aucun commentaire:
Enregistrer un commentaire