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 ?

Kirtan PatelRank #292 · 8.6K reputationPosted Oct 23, 2009, 9:33 PM EDT
Why don't you Directly Use Change Password Control From Tool Box ??
if facing difficulty in using change password control then read below Article
http://www.asp.net/learn/security/tutorial-13-cs.aspx
:)
if my answer helps you please check "Do you like this answer" :)
Amit ChoudharyRank #145 · 15.8K reputationPosted Oct 23, 2009, 9:38 PM EDT
Try to pass the user name directly.... try code given here.. // Get the name of currently logged in user string name=Membership.GetUser().UserName; // Get the complete user object MembershipUser user = Membership.GetUser(name); // chanage the password here user.ChangePassword(user.GetPassword(), newPassword);=================================
Dont forget to mark answer