4

I have a custom master page. I want this master page to be applied for an app(sharepoint hosted). The app contains an aspx page.

By default, the aspx inherits the master page as below:

<%@ Page Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" MasterPageFile="~masterurl/default.master" Language="C#" %>

When I add reference to inherit Seattle.Master as below - the seattle.master is perfectly applied to the app :

<%@ Page Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" MasterPageFile="~site/_catalogs/masterpage/seattle.master" Language="C#" %>

Same way, if I apply my custom master page(below is the code), it doesnt work. The app throws error.

<%@ Page Inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" MasterPageFile="~site/_catalogs/masterpage/MyCustomMasterPage.master" Language="C#" %>

Note: The Seattle.Master and CustomMasterPage.Master are in the same location.

I want to know, how we can apply custom master page to our sharepoint hosted app in Office 365.

Please suggest

Thank You.

  • Why we can not use the existing master page? What is the purpose of module here. – user41269 Apr 9 '15 at 15:32
7

Creating Custom Master Page for Hosted Apps

Create a Module in your project to add the master page that you just created above.

  • Add your custom master page to this module.

  • You will need to modify the elements.xml file so that your master page will go to the master page gallery of your app as below:

    <File Path="ModuleName\CustomMasterPageName.master" Url="_catalogs/masterpage/ CustomMasterPageName.master" Type="GhostableInLibrary"></File>

  • Replace ModuleName with your module name.

  • Replace CustomMasterPageName with your master page name.

  • The above change will deploy the master page into the master page catalog document library of your app.

  • GhostableInLibrary will make sure the document is placed within the document library.

Change the master page name for your App Pages as below:

MasterPageFile="~site/_catalogs/masterpage/ CustomMasterPageName.master"

  • Thanks, This worked. I have another question. I have deployed the masterpage via sharepoint module through Visual Studio. Given the File Path : <File Path="MasterPages\Test.master" Url="_catalogs/masterpage/Test.master" Type="GhostableInLibrary" /> But I dont find the master page in my master page gallary. Any reasons why? Please help. – user2598808 Apr 9 '15 at 6:05
  • 1
    Simply, Your master page will be deployed in APP Web not in your Host Web. – Kaushal Khamar Apr 1 '16 at 5:16

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.