开发者

Overriding BindModel and BindProperty in CustomModelBinder, but BindProperty never hit

开发者 https://www.devze.com 2023-01-08 03:31 出处:网络
I have a custom model binder with public override object BindModel(controllerContext, bindingContext)

I have a custom model binder with

public override object BindModel(controllerContext, bindingContext)

that checks session for an object and creates it if it isn't there, then returns the ob开发者_开发百科ject.

In that same model binder I have:

protected override void BindProperty(controllerContext, bindingContext, propertyDescriptor) , and for some reason  this is NEVER hit on a postback.  

BindModel() is always hit, but breakpoint on first line of BindProperty is never reached. If i comment out the BindModel() override, the BindProperty() WILL be hit. Any idea why?


are you calling base.BindModel(args) in your overridden BindModel()? If not, the DefaultModelBinder won't try to bind the properties and won't call BindProperty.

0

精彩评论

暂无评论...
验证码 换一张
取 消