What is the correct way to create custom model binders in MVC6?

后端 未结 3 735
生来不讨喜
生来不讨喜 2021-01-15 08:43

I\'m trying to follow the steps in this article using a vNext project and mvc 6. I\'ve been reading through the code here but still a little unsure how to implement this.

3条回答
  •  情书的邮戳
    2021-01-15 09:17

    This is my implementation of the MVC 6 RC1 custom Model Binder though I must admit that it's not perfect yet. For some reason the getters of the ViewModel are getting hit before the values are bound to them, so we have to add if (xID == 0) checks, which is lame... and I'm still looking for a solution, anyways, this should help out some: https://github.com/Serjster/IOCModelBinderExample

    Feel free to contribute if you happen to find a solution.

提交回复
热议问题