asp.net-mvc-5 – “确认密码”和“密码”不匹配. MVC5

前端之家收集整理的这篇文章主要介绍了asp.net-mvc-5 – “确认密码”和“密码”不匹配. MVC5前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我无法本地化验证:“确认密码”和“密码”不匹配.在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

猜你在找的asp.Net相关文章