1
이것은 내 사용자 지정 모델 바인더입니다.사용자 지정 모델 바인더가 실행되지 않음
//이 두 라인
모두 시도 : 이public class BaseContentObjectCommonPropertiesBinder : DefaultModelBinder
{
public new object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
if (controllerContext == null)
{
throw new ArgumentNullException("controllerContext");
}
if (bindingContext == null)
{
throw new ArgumentNullException("bindingContext");
}
BaseContentObject obj = (BaseContentObject)base.BindModel(controllerContext, bindingContext);
obj.Modified = DateTime.Now;
obj.Created = DateTime.Now;
obj.ModifiedBy = obj.CreatedBy = controllerContext.HttpContext.User.Identity.Name;
return obj;
}
내 등록 ...
public ActionResult Create(TabGroup tabGroup)
: 내 중단 점 BindModel에서 설정하지만,이 컨트롤러 액션과 해고하지 않습니다
ModelBinders.Binders[typeof(TabGroup)] = new BaseContentObjectCommonPropertiesBinder();
ModelBinders.Binders.Add(typeof(TabGroup), new BaseContentObjectCommonPropertiesBinder());