Model Binding not working

后端 未结 10 1447
别那么骄傲
别那么骄傲 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:14

    Just to contribute another possible reason: I've spent couple of hours looking for an error in my code and the reason for the binder not working in my case was using a model with public fields rather than public properties:

    public int CustomerName;
    

    and it should be:

    public int CustomerName { get; set; }
    

    Been working on ASP.NET MVC for 3 years now and I never came across this before. Hope it saves somebody some frustration ;)

提交回复
热议问题