I'm working on a project using Visual Studio 2008 and have moved from the the MVC 2 Preview to RTM version. We would like to use model validation such as:
public class ViewModel
{
[Required(ErrorMessage="UserName is required.")]
[StringLength(10, ErrorMessage="UserName cannot be greater than 10 chars.")]
public string UserName { get; set; }
}
[HttpPost]
public ActionResult Register(ViewModel model)
{
if (ModelState.IsValid){} // Always true
}
However the ModelState.IsValid always returns true. I have a suspicion that it might be something to do with the version of System.ComponentModel.DataAnnotations.dll that we are referencing, currently version 99.0.0.0, which seems rather odd.
Does anyone know what version of this dll is included with the MVC 2 RTM for Visual Studio 2008?