Is it possible to开发者_StackOverflow社区 add BindAttribute to parameter in action filter?
Each of my view models implements IViewModel { string Prefix { get; } } interface and I would like to set [Bind(Prefix = Model.Prefix)] for Action parameter automatically.
You cannot apply attributes at runtime, they are metadata and are baked into the assembly at compile-time, that's the reason you cannot write [Bind(Prefix = Model.Prefix)]. Model.Prefix needs to be constant and known at compile-time for this to work. Could you describe your scenario in more details, maybe there's another way to achieve your goal.
加载中,请稍侯......
精彩评论