views:

176

answers:

1

Hi.

Is it possible to add BindSttribute to parameter in action filter?

Each of my view models implements IViewModel { string Prefix { get; } } interface and i would like to set BindAttribute(Prefix = Model.Prefix) for Action parameter automatically.

A: 

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.

Darin Dimitrov