Model Binding is not working. MVC3 视图模型绑定不成功
问题出现在POST方法中,当我要将数据提交到后台的时候,绑定的变量值为null
原因是视图中的名称跟Controller中的视图的名称不一致造成的。
假如你视图中的Model采用的是Html.LabelFor(model=>model.Username)这样的方式,
那么你对应的Controller中参数也应该为对应的数据才可以
即:
[HttpPost]
public ActionResult XXX(T model)
{
.....................
}

 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号