The model should be an input parameter for your ActionMethod, and ModelState.IsValid will be checked according to the attributes set in the Model class, in this case, since it is set [Required], it will be checked taking into account zero values,
and if you just want to manually check if there is a value, you can check it directly.
if (user.Name == null) {
return;
}
source
share