What happened to my My Links Web Part?

Well, did you add a link like "file://C:/folder1/folder2"?  In one customer's environment this was the exact issue.  A user added some file system link like the above and ended up with the following symptoms:

1. The user couldn't add the "My Links" web part to his/her MySite.  Whenever he/she tries, it results in an error as shown below


This apparently becomes very bad, as he/she would not be able to access his/her MySite after that (unless they remove the "My Links" web part from the page).

2. And when they browse to http://sharepointmysitehost/_layouts/MyQuickLinks.aspx (that's available in the quick launch menu), they get to see a blank list as shown below


Bad for them a mistake as silly as using a "/" instead of a "\" causes them problems.  Worst, if they had 100 good links and 1 bad link - everything will go for a toss!

When we had a look at the UserLinks table in the SharedServices DB, we could see the bad link formatted like what is shown below


Surprisingly, links with "/" that's pointing to a file does not exhibit this issue.  Further, links that are added with a "file:///" instead of "file://" also does not exhibit this issue.

Well, if we simple delete it off - it fixes the issue, but modifying anything in SharePoint database (even if it's something as simple as the above) is not supported.  Having said that, SharePoint object model comes for our rescue.  Below is the small piece of code we used to get customer's "My Links" back in shape, though with the culprit deleted, which I think they won't mind adding again (correctly that is).

So, the code that brought this customer out of this scenario is:

int count = 0;
string personalSiteUrl = tbMySiteUrl.Text.ToLower();
string personalSiteOwner = tbOwner.Text.ToLower();
string fixer = string.Empty;
using (SPSite oSite = new SPSite(personalSiteUrl))
ServerContext sc = ServerContext.GetContext(oSite);
UserProfileManager upm = new UserProfileManager(sc);
UserProfile up = upm.GetUserProfile(personalSiteOwner);
QuickLinkManager qlm = up.QuickLinks;
foreach (QuickLink ql in qlm.GetItems())
fixer = ql.Url.ToString();
catch (System.UriFormatException uri)
MessageBox.Show("Deleted a total of " + count.ToString() + " bad link(s)");
catch (Exception _e)
MessageBox.Show("Error: " + _e.Message + System.Environment.NewLine + System.Environment.NewLine +
"Stack Trace: " + _e.StackTrace);

It's a windows application with 2 text boxes.  1 that takes the MySite URL as its value and the other takes the MySite owner's account as input.  It also has a button - clicking that does the magic of deleting the nasty little link out.  Oh yes! you should add a reference to the following namespaces though:

using Microsoft.SharePoint;
using Microsoft.Office.Server;
using Microsoft.Office.Server.UserProfiles;
Not always people will end up in the above scenario, but if "fate" frowns on you and you get into the above mess, I hope this post will come handy for you!

Comments (4)

  1. swanl98 says:

    thanks… helped resolve My Links issue

  2. agnel says:

    i have a requirment related to my links webpart.

    I need to open my links webpart in new window when i click on the my profile>>mylinks

  3. Shailesh Palwankar says:

    hi Sridhar

    Can you give us a query to find the URL’s under MY links of any user in the SSP database.

Skip to main content