ModelState.IsValid == false, why?

Omu picture Omu · Nov 24, 2009 · Viewed 143.4k times · Source

Where can I find the list of errors of which make the ModelState invalid? I didn't see any errors property on the ModelState object.

Answer

bastijn picture bastijn · Nov 24, 2009

As you are probably programming in Visual studio you'd better take advantage of the possibility of using breakpoints for such easy debugging steps (getting an idea what the problem is as in your case). Just place them just in front / at the place where you check ModelState.isValid and hover over the ModelState. Now you can easily browse through all the values inside and see what error causes the isvalid return false.

modelstate