Skip to content

Instantly share code, notes, and snippets.

@FernandoVezzali
Last active October 3, 2015 15:58
Show Gist options
  • Save FernandoVezzali/2482342 to your computer and use it in GitHub Desktop.
Save FernandoVezzali/2482342 to your computer and use it in GitHub Desktop.
Model State
public ActionResult Index(Model model)
{
if (ModelState.IsValid)
{
// do stuff here
}
else
{
foreach (ModelState modelState in ViewData.ModelState.Values)
{
foreach (ModelError error in modelState.Errors)
{
Debug.WriteLine(error.ErrorMessage);
Debug.WriteLine(modelState.Value.AttemptedValue);
}
if (modelState.Errors.Count > 0)
{
}
}
}
return View(model);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment