sandeep ram

sandeep ram

  • NA
  • 23
  • 0

Help required in Changing the password for the currently logged in user

Oct 24 2009 1:14 AM
Hi ,

My application is using the Membership API methods.

I have a login page on which the user will be validated using Membership.ValidateUser().

After login he can proceed to use the application.

There is a "Change password" section where I have provided three textboxes -
1.Old pwd
2.New pwd
3. confirm new pwd.

When the user enters the details and clicks on change password button,
I am trying to use the MembershipProvider.ChangePassword() method.

This method requires a MembershipUSer instance so I wrote the following code :

MembershipUser u = Membership.GetUser(User.Identity.UserName);

            if (u != null)

            {

                MembershipProvider mp;

                mp.ChangePassword(u.UserName,TxtPwd.Text,TxtNewPwd.Text);

               

            }


The Problem is that when I am using User.Identity.UserName , I am not getting the username of the currently logged in user. I am getting a blank value - "".


What is wrong ?



Answers (2)