Question

I am trying to create SharePoint 2013 AutoHosted App. In that I have a Default.aspx page. I want this page to be a Master Page child. Or something like that.

I create a SharePoint Hosted App and copy the content that were written on the page. and then Added to my Default.aspx page which were necessary.

I have added bellow line to my page.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AccordionDisplayAppWeb.Pages.Default" MasterPageFile="~masterurl/default.master" %>

I mean I just add MasterPageFile attribute in that.

But it is giving me error like follows.

Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The file '/Pages/~masterurl/default.master' does not exist.

Source Error:


Line 1:  <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AccordionDisplayAppWeb.Pages.Default" MasterPageFile="~masterurl/default.master" %>
Line 2:  
Line 3:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


Source File: /Pages/Default.aspx    Line: 1

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929 

But it is not working.
Can anyone help me to solve this.

Was it helpful?

Solution

When you create an AutoHosted App, the remote web is an ordinary ASP.Net web site, not a SharePoint site.

This means that the SharePoint "extensions" to MasterPageFile like the special token "~masterurl/default.master" isn't working.

You can/should still use a master page on the remote web if you have more than one page, but it'll have no connection to the one used at the SharePoint site. You need to add your own MyMasterPage.Master to the project and then use that in the MasterPageFile attribute like:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AccordionDisplayAppWeb.Pages.Default" MasterPageFile="MyMasterPage.master" %>

While your autohosted app may not use the masterpage of from the SharePoint site it may use the styling through the client chrome control see: How to: Use the client chrome control in apps for SharePoint

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top