This is my custom model binder. I have my breakpoint set at BindModel but does not get fired with this controller action:
public ActionResult Create(TabGroup tabGroup)
...
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;
}
My registration:
// tried both of these two lines
ModelBinders.Binders[typeof(TabGroup)] = new BaseContentObjectCommonPropertiesBinder();
ModelBinders.Binders.Add(typeof(TabGroup), new BaseContentObjectCommonPropertiesBinder());