Skip to main content

Cloud

Userdisp.aspx not Redirecting to Public Profile Page

I found out that when your intranet site and your my sites have different URLs, the userdisp.aspx page is not aware enough to redirect you to the public profile page within it’s own farm. This is a little surprising to me considering you set the my site URL within the shared service provider. After disassembling the code for userdisp and a little digging, I realized that there is a control on userdisp that handles the profile redirection. The control name is ProfileRedirect. ProfileRedirect contains a user control called MySiteRedirectionUserControl. MySiteRedirectionUserControl is what does all of the work, unfortunately for me the code that does the work id obfuscated. So…based on this I decided to write my own code that will be used by userdisp. Not knowing what is really going on I decided to override the oninit method of userdisp. The code looks like the following:

public class MyUserDisplayPage :UserDisplayPage

{

protected override void OnInit(EventArgs evtargs)

{

base.OnInit(evtargs);

try

{

UserProfileManager pm = new UserProfileManager(ServerContext.Current);

UserProfile p = pm.GetUserProfile(this.UserListForm.Item["Account"].ToString());

if (p != null)

Page.Response.Redirect(p.PublicUrl.ToString());

}

catch { }

}

}

Notes:

  • You must call the base oninit first, otheriste the UserListForm object will be null
  • The namespaces used are Microsoft.SharePoint.AppkicationPages, Microsoft.Office.Server, and Microsoft.Office.Server.UserProfiles
  • If a user does not exist in the profile store then you will not see the public profile page, the userdisp.aspx page will show.

I am currently working with Microsoft on a resolution that does not involve this code change, so I they have something for me other than setting the portal URL (yes they did suggest that and I said that was unacceptable), I will post another blog regarding how to fix it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.