Is there any good reason to use FormCollection instead of ViewModel?

前端 未结 11 1587
离开以前
离开以前 2020-11-27 15:09

I\'ve inherited a code base written in ASP.Net MVC 4. Every post method takes a FormCollection. Aside from annoyance of having to access the values through quot

11条回答
  •  误落风尘
    2020-11-27 15:28

    There are type of SPA apps where you have no idea about your model (there is no ViewModel at all and views are created dynamically (for short ;))), so FormCollection is your only choice where you implement custom post validation having entire page input values... If your view has a knowledge about the model then, of course, you can use your concrete ViewModel object. That's easy ;)

提交回复
热议问题