ModelBinder validation breaks on getter using reflection

前端 未结 1 1310
太阳男子
太阳男子 2021-01-15 18:23

I\'ve ran across a problem which seems to be related to reflection and model binder validation, and FormatterParameterBinding.ExecuteBindingAsync(..) in particu

相关标签:
1条回答
  • As a general rule you should avoid using complex classes like PropertyInfos that have properties with other complex types...in classes used for model binding, but you should use just simple classes that contains JUST THE PROPERTIES you need for the model binding process, moreover the whole object graph should contain no loops. Model binding process analyze the type of properties for different purposes (validation attributes, etc.) an i may recusrively analyze the sub-properties of contained in the type of eac property...so complex .net classes containing loops and a lot of other .net types may break it. Try making the property PropertyInfos internal or turn it into a method so it shgould not be processed, by any model binder component.

    0 讨论(0)
提交回复
热议问题