Change User Password in ASP.NET Forms Authentication

前端 未结 5 1877
一生所求
一生所求 2021-01-02 16:47

I code in C# (ASP.NET) and am using Forms authentication.
I would like to know which is the best method to change a user password without using the asp:ChangePassword c

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-02 17:43

    On the off chance someone is using the ApplicationUser and not the Membership - as I was because I did not want to set a Membership Provider - you can change the password this way:

                Dim manager = New UserManager()
                Dim userChange As ApplicationUser = manager.FindById(IDUser)
    
                userChange.PasswordHash = manager.PasswordHasher.HashPassword(newPassword.Value)
                Dim val As Object = manager.Update(userChange)
    

    Hope this helps someone

提交回复
热议问题