Hello everyone, please tell ModelState.IsValid why ModelState.IsValid does not see a validation error when assigning a knowingly incorrect model to the ViewData.Model property? Here is the class
public class Class1 { [Required] public string EnterName { get; set; } [Required] public string EnterMessage { get; set; } } But the method of action
public ActionResult Index(string EnterName, string EnterMessage) { ViewData.Model = new MvcApplication5.Models.Class1(); ViewBag.M = ModelState.IsValid; return View(); } As can be seen from the action code, I assign a class with empty properties, and this is not valid due to the [Required] attributes, however ViewBag.M = ModelState.IsValid; gives true. Why ??