我正在构建一个 MVC4 应用程序,并且正在使用 PropertiesMustMatch 和 ValidatePasswordLength 进行密码验证。
奇怪的是我不断收到错误消息说它们不存在,“无法解析 PropertiesMustMatch”
这是我的代码。有任何想法吗??
[PropertiesMustMatch("Password", "ConfirmPassword",
ErrorMessageResourceName = "PasswordsMustMatch",
ErrorMessageResourceType = typeof(ValidationStrings))]
public class RegisterModel
{
[Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ValidationStrings))]
[DisplayName("Username")]
public string UserName { get; set; }
[Required(ErrorMessageResourceName = "Required",
ErrorMessageResourceType = typeof(ValidationStrings))]
[DataType(DataType.EmailAddress)]
[DisplayName("Email")]
public string Email { get; set; }
[Required(ErrorMessageResourceName = "Required", ErrorMessageResourceType = typeof(ValidationStrings))]
[ValidatePasswordLength(ErrorMessageResourceName = "PasswordMinLength", ErrorMessageResourceType = typeof(ValidationStrings))]
[DataType(DataType.Password)]
[DisplayName("Password")]
public string Password { get; set; }
[Required(ErrorMessageResourceName = "Required",
ErrorMessageResourceType = typeof(ValidationStrings))]
[DataType(DataType.Password)]
[DisplayName("Confirm password")]
public string ConfirmPassword { get; set; }
}