Model state not valid

前端 未结 2 1445
感情败类
感情败类 2021-01-08 01:24

So I have a view called index that lays out all of the threads in my database. Then inside that view I\'m loading all the comments on the threads. When I call on my form tha

相关标签:
2条回答
  • 2021-01-08 01:56

    Before checking your error, you need to know why is the model state invalid. You can easily do that by debugging and seeing the list of errors.

    The second error should be a separate questions as I believe to be written in stackoverflow guidelines.

    0 讨论(0)
  • 2021-01-08 02:00

    Use the code below to iterate through the errors. Then you can see what field and what object is failing on validation. And then you can go from there. Just looking at the IsValid property is not going to give enough information.

    var errors = ModelState.Values.SelectMany(v => v.Errors);
    

    And then loop through the errors.

    0 讨论(0)
提交回复
热议问题