How to get a specific user profile through user identifier
I'm working on an asp.net application I'm currently working on the administrator
page. As an administrator i need to retrieve a specific user information stored
within profile property in web.config. I used ProfileCommon class with GetProfile
method that i built my self because that class and method are not in .Net
framework Don't mind my terminology I'm still a novice
<profile>
<properties>
<add name="PostalCode" type="System.String" />
<add name="Country" type="System.String" />
</properties>
</profile>
This is how i define the class, properties and GetProfile method
public class ProfileCommon : ProfileBase
{
public string PostalCode
{
get
{
return (string)HttpContext.Current.Profile.GetPropertyValue
("PostalCode");
}
set
{
HttpContext.Current.Profile.SetPropertyValue("PostalCode", value);
}
}
public string Country
{
get
{
return (string)HttpContext.Current.Profile.GetPropertyValue("Country");
}
set
{
HttpContext.Current.Profile.SetPropertyValue("Country", value);
}
}
public virtual ProfileCommon GetProfile(string username)
{
return Create(username) as ProfileCommon;
}
}
This is how I'm trying to retrieve information on a specific user
// I retrieved the unique identifier of a user in my Order table.
Customer = Membership.GetUser(new Guid(orderRow["CustomerID"].ToString()));
// I try to use it to retrieve a user specific info stored in web.config
ProfileCommon pro = new ProfileCommon();
CustomerProfile = pro.GetProfile(Customer.UserName);
postalCodeLabel.Text = CustomerProfile.PostalCode;
countryLabel.Text = CustomerProfile.Country;
please is their any other way I can retrieve this information or is there anything I'm
not doing right cos I'm suspecting the definition of my GetProfile method. I will really appreciate it if I can get the solution to this problem