I am trying to deploy a "plain" .aspx page (no code-behind) to a library in a SharePoint site using a module (web scoped feature). I don't even really need an .aspx page, all I really need is an HTML page, but I need it to use the site's master page for site navigation, etc.

I've used a technique similar to this answer to make a minimal page that will load the necessary JSOM files and provide me a place to put some plain HTML markup. I'm not using any ASP.NET controls other than the basic placeholders. Here's what my markup looks like:

<%@ Page Language="C#" MasterPageFile="~masterurl/default.master" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>

<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">

    <!-- links to style sheets here -->

    <meta name="WebPartPageExpansion" content="full" />

    <!-- links to scripts here -->

    <SharePoint:FormDigest runat="server" />

<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">

    <!-- plain ol' HTML in here -->


<asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server">
My Page Title Here

<asp:Content ID="PageTitleInTitleArea" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea" runat="server" >
My Page Title Here

The problem is that after deploying the page, when you load the page it doesn't pull in the site's master page. Everything else works, scripts get loaded and the page is fully functional, just nothing that comes with the master page is there (site navigation etc.) However, if I upload the page through a browser into the library, then it starts pulling the master page correctly.

I tried removing the Type="GhostableInLibrary" attribute in the module in hopes that it was a ghosting/unghosting problem, and that by treating the page as unghosted it would somehow fix the issue, but it didn't.

I also tried editing the title property of the file once it was deployed to see if an Update would cause the same changes that happen when I upload manually, and I tried grabbing the file in a feature receiver and calling Update directly on the SPFile object, but neither of those worked either.

This is all through a Sandbox solution, which is why:

  • I can't deploy the page as an application page to the 15 hive.
  • I can't deploy my HTML to the site as an HTML file, and programmatically (in a feature receiver) create a new wiki page, add a CEWP to the page, and link the CEWP to my HTML file. (I could create the page, but SPLimitedWebPartManager is not available in Sandbox solutions.)

So, does anyone know what is going on here and how I can get the page to reliably pull in the master page?

  • What happens if you remove the MasterPageFile property from <%@ Page Language="C#" MasterPageFile="~masterurl/default.master" %>? – user2536 Aug 31 '16 at 7:36
  • @DanielZiga on initial deployment, the behavior is the same (page loads without master page), but if I manually upload it, it then throws an error: "Content controls are allowed only in content page that references a master page". So it seems the MasterPageFile attribute in the page directive is necessary. – Dylan Cristy Aug 31 '16 at 12:52

Your Answer

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

Browse other questions tagged or ask your own question.