I've received a WSP where the contained pages reference the master page as shown in the title. The pages are deployed to a folder under the Site (ie http://app.contoso.com/PagesFolder/welcome.aspx). It throws a FileNotFound error saying /PagesFolder/site/_catalogs/masterpage/m.master does not exist.

Where is the problem? Is that as expected or is there something I need to configure to make the token work?

  • With which property do the page reference the master page? – James Love Jan 4 '13 at 21:09

Check the MasterPageFile property is being set correctly and you could set any master page from gallery e.g. MasterPageFile="~site/_catalogs/masterpage/v4.master".

example usage in a Page layout:

<%@ Page Language="C#" Inherits="Microsoft.SharePoint.WebPartPages.WikiEditPage" MasterPageFile="~site/_catalogs/masterpage/v4.master" meta:webpartpageexpansion="full" meta:progid=”SharePoint.WebPartPage.Document" %>


There are different ways you can refer the master page in your page layouts:

  • This is a relative or absolute path to a master page. Relative locations are based on the page instance's location - i.e. "../_catalogs/masterpage/custom.master" will find custom.master in the current SPWeb's master page gallery, which may or may not be the top-level site's master page gallery.
  • Site-Relative Master Page ~site/_catalogs/masterpage/custom.master.
  • Site Collection-Relative Master Page ~sitecollection/_catalogs/masterpage/custom.master.
  • Here's the Page Directive: <%@ Page Language="C#" MasterPageFile="~site/_catalogs/masterpage/CustomDefault.aspx" Inherits="MyApp.Welcome" Title="Welcome" %> – Sam Larko Jan 7 '13 at 15:28
  • Your pages are created under a sub-folder "PagesFolder" and the MasterPageFile directive looks for the master page in the following path: "/PagesFolder/site/_catalogs/masterpage/CustomDefault.master" which definitely is not a valid path. Could you please also make sure that CustomDefault.master is present in the master pages gallery? – Falak Mahmood Jan 7 '13 at 22:36
  • I have updated my post with different techniques to refer master page. – Falak Mahmood Jan 7 '13 at 22:44
  • Thanks for the answer, which helped me in one of my scenario, of an Office-365 Site. Using the below URL I could refer the root-site master-page: ~sitecollection/_catalogs/masterpage/<master-page>.master – user24460 Mar 18 '14 at 10:43

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.