Using ModelBinder attribute vs. ModelBinders.Add()

前端 未结 2 532
执笔经年
执笔经年 2020-12-15 04:49

Can someone tell me the pros/concs to using [ModelBinder()] attribute vs. registering model binders via ModelBinders.Add() in global.asax?

2条回答
  •  星月不相逢
    2020-12-15 04:53

    It looks to me like the advantage of using an attribute rather than adding to the model binders collection in Global.asax is that you can tell the method (or class) which specific binder to use rather than associating the binder with a specific type. Then you can create the model based on a context rather than a type.

提交回复
热议问题