Model is null while submitting the form in partial view in MVC5

后端 未结 2 1461
醉梦人生
醉梦人生 2021-01-25 16:51

I am just trying to learn MVC and facing some issues.When I am submitting my partial view, I am getting null in Model Blog inside Create Method.

What I

2条回答
  •  隐瞒了意图╮
    2021-01-25 17:37

    Your class Blog only contains fields, not properties so the DefaultModelBinder cannot set their values. Change it add getters/setters

    public class Blog
    {
        public string Name { get; set; }
        public string URL { get; set; }
    }
    

提交回复
热议问题