C# .NET MVC3 ModelState.IsValid

前端 未结 3 536
一个人的身影
一个人的身影 2021-02-01 09:23

Im using JSON to post data from a form and ModelState.isValid() returning false, i put a WriteLine for all incoming data and everything looks fine data wise, is there a way to d

3条回答
  •  攒了一身酷
    2021-02-01 09:58

    You can find the errors in the ModelState.Values collection. Every value has an Errors collection that contains all the model errors for that property.

    var errors = from v in ModelState.Values 
                 where v.Errors.Count > 0 
                 select v.Errors;
    

提交回复
热议问题