我正在使用模型绑定器来操作一些数据。我想从 .net 获取绑定模型并对其进行操作。
public class FilePointerBinder : IModelBinder
{
public new object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
//MyCustomSubModel value = new MyCustomSubModel();//THIS IS NOT GOOD
MyCustomSubModel value = (MyCustomSubModel)GetTheDefaultValueFromSomeWhere();
value.Id = 0;
return value;
}
}
编辑
public class User{
public int Id{get;set;}
public FilePointer File{get;set;}// this is null
}