我无法本地化验证:“确认密码”和“密码”不匹配.在MVC5
[required] [StringLength(100,ErrorMessage = "The {0} must be at least {2} characters long.",MinimumLength = 6)] [DataType(DataType.Password)] [Display(Name = "Password")] public string Password { get; set; } [DataType(DataType.Password)] [Display(Name = "Confirm password")] [Compare("Password",ErrorMessage = "The password and confirmation password do not match.")] //Why not display this message??????? public string ConfirmPassword { get; set; }
请帮我把它本地化
解决方法
你有两个选择可以解决这个bug:
– 选项1
更改:
[Compare("Password",ErrorMessage = "The password and confirmation password do not match.")]
至
[System.Web.Mvc.Compare("Password",ErrorMessage = "Your custom error message")]
– 选择2(我推荐这个)
我们需要更新我们的ASP.NET MVC 5.在Visual Studio中,转到Package Manager Console并键入:
PM> update-package
你得到一个错误在:
public ApplicationDbContext() : base("DefaultConnection") { }
该错误是由MVC 5的内部结构的更新引起的.要解决这个错误,请执行以下操作:https://stackoverflow.com/a/23090099/2958543