+977-9849845061

[SOLVED] How to Reset User Password with UserManager in ASP.NET Identity

I was wondering if there is a way to reset password with UserManager of ASP.NET MVC 5  some days ago and finally I got simple and effective solution Resetting users password is one of the features that we need in our application. Well, there are many solutions that you can apply but the most simple and effective would be as mentioned below. 

I was wondering if there is a way to reset password with UserManager of ASP.NET MVC 5  some days ago and finally I got simple and effective solution

Resetting users password is one of the features that we need in our application. Well, there are many solutions that you can apply but the most simple and effective would be as mentioned below.

userManager.ResetPassword(UserID) : Resets a user’s password.

userManager.AddPassword(UserId, “New_Password”) : Assigns new password to User.

 

Step I: let’s Create a ViewModel for resetting password for User as ResetUserPasswordViewModel as

I was wondering if there is a way to reset password with UserManager of ASP.NET MVC 5  some days ago and finally I got simple and effective solution Resetting users password is one of the features that we need in our application. Well, there are many solutions that you can apply but the most simple and effective would be as mentioned below. 

 

Code Snippet

 

Step 2: Add a method called ResetUserPassword accepting Parameter UserId as

Step 3: Create View with ResetUserPasswordViewModel

 

Step 4: Add New method called ResetUserPassword like

Note: This method should be of type [HTTPOST] as HTTPPostAtttibute

 

Now let’s add an action button in UserWithRoles view to enable ResetUser Password functionality in ASP.NET Identity. Note, we have already created ListUser method returning the list of Users with Roles in our Previous Example. [http://aryalnishan.com.np/asp-net-mvc/list-all-users-with-associated-roles-in-asp-net-identity]

 

UserWithRoles view after adding Reset User Password Button looks like following.

 

 

Running Application. 

Now let’s run the solution after rebuilding and navigate to /ManageUsers/UserWithRoles  

 

Form when submitted after providing New Password, will reset password to new password of the respective user.

 

You can download Full Working Project from https://github.com/nishanaryal/ASP.NET-MVC

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...