モデルバインダーを使用して一部のデータを操作しています。そして、バインドされたモデルを .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
}