How to create the Profile object of user??

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hey

ASP.NET 2.0

I'm developing a web portal where users must login to. As far as I know all
users are accessible from the MembershipUserCollection. I know that current
user is also accessible via the Profile object in the webpage, but I want to
access the properties of one of the other users. So I guess I have to create
an instance of the ProfileCommon class... I have the username of the user I
want to create a ProfileCommon object of, but my problem is that I don't
know how to it....???
 
You can use this code:
public List<MembershipUserWrapperForMP> GetMembers(string usernameToFind)
{

List<MembershipUserWrapperForMP> memberList = new
List<MembershipUserWrapperForMP>();

if (usernameToFind != null)
{
MembershipUser mu = Membership.GetUser(usernameToFind);
if (mu != null)
{
MembershipUserWrapperForMP md = new
MembershipUserWrapperForMP(mu);
ProfileCommon pc =
(ProfileCommon)ProfileBase.Create(mu.UserName, true);
md.FirstName = pc.FirstName;
md.LastName = pc.LastName;
memberList.Add(md);
}
}
return memberList;

}
 
Thanks for the tip!

This was about getting the profile of a different user, this code get the
profile of a different user:
ProfileCommon userProfile =
(ProfileCommon)System.Web.Profile.ProfileBase.Create("username", true);

I'm posting this reply in case somebody else came accross the same problem

Thanks for your tip Saeed
 
Back
Top