I am just getting started with ASP.Net MVC 3 and am confused on this point.
In some examples when an action in a controller is run that contains inputs then a check is made to ensure ModelState.IsValid is true. Some examples do not show this check being made. When should I make this check? Must it be used whenever an input is provided to the action method?
It is exactly when you are using a view model provided as action argument and this view model has some validation associated with it (for example data annotations). Here’s the usual pattern:
and then: