Currently the [Required] attribute can be used on properties but not on the type itself or on the parameter. So when sending a request with empty body to the POST action below, the ModelState.IsValid would return true even though everything is missing. Right now we don't have good ways of specifying a required body parameter.
public POST(LoginModel login)
{
if (ModelState.IsValid)
{
// do something with the login parameter
}
}
public class LoginModel
{
[Required]
public string UserName { get; set; }
[Required]
public string Password { get; set; }
}
Comments: This is a dup of issue 24.