I can see that my ModelState.Values[x].Errors is correctly populated with the two validation errors for a single property.
If I use a @Html.ValidationSummary() in my view, it correctly displays both errors…. albeit at the top of the page, and not next to the offending input.
Using @Html.ValidationMessageFor(model => model.MyProperty) displays the first error only for that property!
How do I show both errors, next to the appropriate input?
One solution is to implement your own extension method on HtmlHelper that does something different to the default ValidationMessageFor behavior. The sample @Html.ValidationMessagesFor method below will concatenate multiple error messages that have been added to the ModelState during server-side validation (only).
This is useful if you have custom business validation you’re applying across a collection belonging to your model (for example, cross-checking totals), or checking the model as a whole.
An example using this, where a collection of Order.LineItems are validated server-side: