Jul 12, 2012

MVC Html helper values and ModelState

Surprisingly, if you do a return View(model); in your postback action, the @Html.EditorFor helper does not use the values from the passed model, but the values from the ModelState are used instead. Supposedly for form input persistence reasons, but does not make sense to me since you explicitly pass on the model. To still use the html helpers and the model, you can clear the ModelState first in your action: ModelState.Clear();