Welcome to MSDN Blogs Sign in | Join | Help
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

Posted: Wednesday, April 25, 2007 10:05 PM by jasward
Filed under:

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required) 

  
Enter Code Here: Required

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Page view tracker