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
Responding to the title question: yes.
There are some situations that FormCollection
needs to be used. For instance, suppose a ViewModel
that has a property that implements the 1 to N relation (in concrete case, a TimesheetViewModel
with ICollection
), and the Controller has to perform a validation between the time entries to not get a time collision between the end time of an entry and the start time of the following entry. To mark a related entry with a validation error, how can be the line index be retrieved?
Well, with the default model binding, the index value is lost in the Controller logic. Fortunately, FormController
stores the index you used in the View and a more specific validation can be done.