I try to add a link to users mysite only if the current user is on his mysite (Or on mysite host).

Is there a solution to add something on the masterpage to check this in .Net? I googled a lot but didn't find anything to achieve this directly on masterpage.


You can use JavaScript API to retrieve current User MySite URL and then compare and show or hide link based on that

    url: _spPageContextInfo.webAbsoluteUrl + "/_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=UserUrl",
    method: "GET",
    headers: {
        "accept": "application/json;odata=verbose",
    success: function (data) {
        var userUrl = data.d.UserUrl;
    error: function (err) {
        alert("Request Failed");
| improve this answer | |
  • if Javascript is an Option, you could do it simply by the values of _spPageContextInfo Object webTemplate gives you Information of the template, the current web is originated (eg 21 is personal site, 54 is for mysiteHost, 1 is for Teamsite) webTitle uses the DisplayName of the user, the current MySite belongs to siteServerRelativeUrl consists of the subsite for personal Sites and the accountName of the user the currentMySite belongs to (eg /personal/pexlel) – Leopold Lerch May 27 '15 at 13:54

you have to build your own control and place it on the masterpage either directoy or via delegate control

You are not able to execute code directly in the masterpage

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.