Accessing profile data from a web service
I recently had a need to access the Profile object from a web service which I was calling from a JavaScript method using ASP.NET AJAX.
Looking around on the web people said it couldn't be done. Well never one to take no for an answer, I managed to play around and work it out. Here it is:
//get the profile object for the user
System.Web.Profile.ProfileBase userProfile = System.Web.Profile.ProfileBase.Create("Insert Username");
//get the value
string email = userProfile["EmailAddress"].ToString();
If you wanted to change the value, you can do this:
userProfile["EmailAddress"] = "someone@somewhere.com";
userProfile.Save();
Hope this helps!
- Jason