I edited my masterpage with VS. I deploy the solution but I see the old masterpage. My Masterpager is

<File Path="MasterPages\MY.master" Url="MY.master" Type="GhostableInLibrary">
  <Property Name="Title" Value="MY Master Page"/>
  <Property Name="UIVersion" Value="15"/>

How can I tell SharePoint to use my new version of the MasterPage ?


You have to create a feature to attach this master page to your site.

SPWeb objWeb = properties.Feature.Parent as SPWeb;
    objWeb.AllowUnsafeUpdates = true;
                    objWeb.MasterUrl = SPUtility.ConcatUrls(objWeb.ServerRelativeUrl, "/_catalogs/masterpage/MY.master");

                    objWeb.CustomMasterUrl = SPUtility.ConcatUrls(objWeb.ServerRelativeUrl, "/_catalogs/masterpage/MY.master");
                    objWeb.AllowUnsafeUpdates = false;

Also try to validate your master page by: http://chayadigital.wordpress.com/2010/10/14/apply-custom-master-pages-in-sharepoint-2010/

  • I have to put the code in the EventReceiver of th Feature ? I try the code : $masterPage = "mywebsite.com/_catalogs/masterpage/MY.master"; $WebUrl = "mywebsite.com"; $objWeb = Get-SPWeb($WebUrl); $objWeb.MasterUrl = $masterPage; $objWeb.CustomMasterUrl = $masterPage; $objWeb.Update(); It say the MY.master doesn't exist ... but i can see it in my browser
    – Sancho
    May 22 '14 at 9:16
  • Are you using powershell? Try this: $masterPage = "/_catalogs/masterpage/MY.master"
    – Aanchal
    May 22 '14 at 9:23
  • I think powershell more easy just for one time. Now the code doesn't say the masterpage doesn't exist but i don't see the change in my page Index.aspx, i see the older html code.
    – Sancho
    May 22 '14 at 9:28
  • Did you set objWeb.AllowUnsafeUpdates = true;
    – Aanchal
    May 22 '14 at 9:30
  • Also check other sharepoint pages like Home.aspx if master page is updated there or not?
    – Aanchal
    May 22 '14 at 9:31

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.