简体   繁体   中英

Work with HTML.EditorForPassword() in MVC4

I created a "Editlogin.cshtml" page where I can edit all properties of an user. My user has password so when I change a his password then it works okay. However when I do not write any passwors, my page has to write me a password, but sometimes I do want to leave the previous password. I use Entity Framework and I use an attribute for Password property in a model class:

    [Required(ErrorMessage = "Please type Password", AllowEmptyStrings = false)]
    public global::System.String Password
    {
        get { //omitted}
        set { //omitted}
    }

It is a double-edged weapon. When I create new user, I must have to write new password. However, if I edit an user, I would like sometimes to leave a previous password. How to solve it?

为什么不通过单独的功能(更改密码)从表单编辑中选择退出密码更改,出于安全目的,重置密码字段非常有用。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM