Closed IanKemp closed 5 years ago
It looks like this question has a good answer on StackOverflow. Have you tried the second answer on the StackOverflow question. That's https://stackoverflow.com/a/18356522
I'm not asking how to achieve this behaviour, I'm asking why CustomModelBinderAttribute
doesn't allow said behaviour out-of-the-box, and whether that is intentional or not. In other words, what is/was the design decision behind CustomModelBinderAttribute
? Especially considering that e.g. https://msdn.microsoft.com/en-us/magazine/hh781022.aspx seems to imply it should work (section "Adorning Models with Custom Attributes").
As for the given solution, it is somewhat intrusive because it necessitates replacing the default model binder. That wouldn't be necessary if CustomModelBinderAttribute
behaved as the linked MSDN article seems to suggest it should.
Not supporting [CustomModelBinder]
on properties was intentional. Can't say I remember the reason however.
Thank you for your feedback. We're closing this issue as the questions asked here have been answered.
The
CustomModelBinderAttribute
class seems to promise a way to use an attribute to link a model property to use an arbitrary model binder, but unfortunately it doesn't seem to work. Other people have had the same problem.Looking at how
CustomModelBinderAttribute
is used in this project, it seems that you don't intend for it to be applied on anything except types (and params) - can you confirm this?