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

前端 未结 11 1545
离开以前
离开以前 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:37

    Well with Forms Collection you will find a quick way to get the values of a form. Otherwise you have to create a class that mimics the Form Fields and people are sometime lazy to create custom classes for less important/rarely used Forms.

    No there is no extra benefit (in fact limited) of forms collection over a custom class as action parameters and it should be avoided whenever possible.

提交回复
热议问题