I am checking my database in Create(FooViewModel fvm){...}
to see if the fvm.prop1
and fvm.prop2
already exist in that combination; if so, I want to add an error to the modelstate, then return the whole view. I tried:
public ActionResult Create(FooViewModel fvm){
if (ThatComboAlreadyExists(fvm)) {
ModelState.AddModelError("Model", "There is already one like that");
return View(fvm);
}
}
...but I get no display of errors in the Html.ValidationSummary
, which is where I assume they would appear. I have the suspicion that "Model" is not the right key, but I haven't been able to find anything a la Google.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…