I am trying to get Public URL of all my sites. i have ran this code for every loginname and its working fine except for one user. for this user i am getting null in up.PersonalSite. i have checked it manually and mysite for that user exists. any ideas why up.personalsite is returning null. any suggestions?
SPServiceContext context = SPServiceContext.GetContext(Site);
UP.UserProfileManager upm = new UP.UserProfileManager(context);
UP.UserProfile up = upm.GetUserProfile(LoginName);
if (up.PersonalSite == null)
return "#";
else
return up.PublicUrl.OriginalString;
Maybe, you saw Profile pages for existing users? (http://localhost/my/Person.aspx?accountname=DOMAIN%5CVPupkin) The user should create your site itself or you can create programmatically with
SPServiceContext context = SPServiceContext.GetContext(Site);
UP.UserProfileManager upm = new UP.UserProfileManager(context);
UP.UserProfile up = upm.GetUserProfile(LoginName);
up.CreatePersonalSite();