ASP.NET Membership change password not working

前端 未结 10 1692
心在旅途
心在旅途 2021-02-19 18:48

I have this code for changing a user\'s password when they click the password reset button (with extra code to log to ELMAH so I can try to figure out what is going wrong).

10条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-19 19:44

    Hmm, I've always used

    bool MembershipUser.ChangePassword(string oldPassword, string newPassword)
    

    I've never had an issue with it returning true and the password not being changed correctly. As fas as I can tell your code looks ok. It is difficult to follow, with all the Elmah noise in there. (you might want to remove it or replace with a simple log call so it's easier to follow).

    Verify that the string id that you pass as an argument corresponds to the UserId of the intended user. You might be sending the userId from some other user and changing that users password instead.

提交回复
热议问题