Posts

Showing posts from July, 2012

SharePoint 2010 - MySite Redirection

When user's click a user's name in a document library, etc, a file userdisp.aspx controls where the user is directed. Assuming you want to have all user links bring users to My Sites, you can start off creating the user control, by the following code on http://blogs.sharepointguys.com/brendon/sharepoint-2007/programming/redirect-to-your-own-mysite-landing-page/ and then in the RedirectIfNecessary(SPListItem user) you can utilize the following code.

if (Request.QueryString["id"] != null) { SPSite _site = SPContext.Current.Site; SPServiceContext _serviceContext = SPServiceContext.GetContext(_site); UserProfileManager _userProfileManager = new UserProfileManager(_serviceContext); string _mySiteUrl = _userProfileManager.MySiteHostUrl; string _profileUrl = string.Empty; int userID = 0; if (int.TryParse(Request.QueryString["id"].ToString(), out userID)) { SPUser profileUser = SPContext.Current.Web.SiteUsers.GetByI…