I am applying my custom master page on application layout pages which I am deploying using Visual Studio. My issue is I have to copy my custom master page in the same directory where my layout pages exist otherwise it's not working.

I want to deploy my custom master in the default master page directory and refer it to my layout pages.

Is it possible? Or do I have to copy my custom master page in the layout page directory?

2 Answers 2


Deploy Master Page through visual studio with adding module template
Add your custom master page in module

In the Modules Element.xml File(This will deploy your master in to _catalogs/masterpage)

<?xml version="1.0" encoding="utf-8"?>
  <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="MasterPage" Url="_catalogs/masterpage" RootWebOnly="TRUE" xmlns="http://schemas.microsoft.com/sharepoint/">
      <File Path="MasterPages\CustomMasterPage.master" Url="CustomMasterPage.master" Type="GhostableInLibrary"/>

Set Master Page through code

using (SPWeb currentWeb = (SPWeb)properties.Feature.Parent)
                    currentWeb.AllowUnsafeUpdates = true;
                    Uri masterUri = new Uri("Path of custom master page");
                    currentWeb.MasterUrl = masterUri.AbsolutePath;
                    currentWeb.CustomMasterUrl = masterUri.AbsolutePath;
                    currentWeb.AllowUnsafeUpdates = false;


Please refer this link

Hope it helps


You can deploy your master to the "Masterpages" library at _catalogs/masterpage.

And in your application pages you set the DynamicMasterPageFile property to ~masterurl/your_masterpage_name_here.master and then it should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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