asp.net mvc strongly typed helpers - should your render binding object be the same as your posting object?

前端 未结 7 1408
刺人心
刺人心 2021-01-02 22:52

i see that asp.net mvc 2 has strongly typed helped and looking initially at the way it works i think maybe i am doing something wrong in asp.net mvc 1 in terms of data bindi

7条回答
  •  长发绾君心
    2021-01-02 23:38

    Real problem is - current accepted approach ignores SRP for view models a bit - edit form acts as input and output simultaneously.

    People haven't accepted yet dividing view model into, as i call them, input view model and output view model (for many - even creating view model layer is too much). Therefore - Mvc2 currently lacks support for this (you aren't supposed to have strongly typed view that's not input and output at the same time) mainly because of vagueness and lack of broadly accepted approaches.

    But i do think that there's a gain (ok... it's actually a trade off) in going deeper and separating view model into 2 of them. And i won't be surprised if this idea will evolve and eventually become widely accepted.

    Actually - current approach even has a name - Thunderdome principle. And if guys like Jeremy D. Miller says this is correct, community won't bother and won't search for anything else.


    From practical point of view - some of the issues you can mitigate through providing correct metadata (you might want to check out fluent model metadata provider).

提交回复
热议问题