0

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.

1 Answer 1

2

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

3
  • Ohk sir. But I have downloaded one App from the App store of SharePoint and in that I saw the Page that was inhering my sites Master Page. So I was trying to develop some what similar app for my learning. So to put App in Azure Market for sell don't I have to create Autohosted App? Jun 17, 2013 at 13:13
  • And the other thing when I created SharePoint Hosted App and Deployed it to my Office 365 environment It was working nicely. Jun 17, 2013 at 13:18
  • 1
    An app in the marketplace can also be SharePoint hosted. If you need it to be AutoHosted then you can still use the styling from SharePoint see updated answer, but not the entire master page Jun 17, 2013 at 13:31

Your Answer

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

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