Model Binding not working

后端 未结 10 1451
别那么骄傲
别那么骄傲 2021-02-06 01:52

I have the following POCO classes:

public class Location
    {
        public int LocationId { get; set; }
        public string Name { get; set; }
        publi         


        
10条回答
  •  暖寄归人
    2021-02-06 02:07

    Mine was a bit unique case, but hope it helps someone in similar context. I had my View Model implementing IValidatableObject, and the Validate method from this interface was returning a null if success. It had to return an empty IEnumerable. Hence the binding was actually happening but crashing.

    Basically when you get this issue, use Fiddler to look at posted data, make sure the posted variables match the properties(not fields!) on your view models, and put a break point on the View Model constructor to ensure the Routing Engine hits the correct POST method. Good luck!

提交回复
热议问题