UserProfile.PublicUrl Property
This member overrides ProfileBase.PublicUrl.
Namespace:
Microsoft.Office.Server.UserProfiles
Assembly: Microsoft.Office.Server.UserProfiles (in Microsoft.Office.Server.UserProfiles.dll)
Assembly: Microsoft.Office.Server.UserProfiles (in Microsoft.Office.Server.UserProfiles.dll)
Gets the MySite Url for the Current User
The follwoing code returns the Public Url for the Current User from UserProfile.
SPSite _site = SPContext.Current.Site;
SPServiceContext context = SPServiceContext.GetContext(_site); UserProfileManager profileManager = new UserProfileManager(context);
//Get the Current User Login Name
string UAccount = SPContext.Current.Web.CurrentUser.LoginName; //Pass the Login Name to Profile Manager to get the properties for the User Profile
UserProfile u = profileManager.GetUserProfile(UAccount);
//PersonalUrl property gets the MySite Public url of the given user
Response.Write ( u.PublicUrl.ToString() );
SPSite _site = SPContext.Current.Site;
SPServiceContext context = SPServiceContext.GetContext(_site); UserProfileManager profileManager = new UserProfileManager(context);
//Get the Current User Login Name
string UAccount = SPContext.Current.Web.CurrentUser.LoginName; //Pass the Login Name to Profile Manager to get the properties for the User Profile
UserProfile u = profileManager.GetUserProfile(UAccount);
//PersonalUrl property gets the MySite Public url of the given user
Response.Write ( u.PublicUrl.ToString() );
- 11/29/2011
- Shantha Kumar