problem: When I assigned “application.master” or “layouts.master” pages as master page to my new developed web page, I received this error from share point:
The referenced file '/layouts.master' is not allowed on this page. at System.Web.UI.TemplateParser.ProcessError(String message) at System.Web.UI.BaseTemplateParser.GetReferencedType(VirtualPath virtualPath, Boolean allowNoCompile) at System.Web.UI.PageParser.ProcessMainDirectiveAttribute(String deviceName, String name, String value, IDictionary parseData) at System.Web.UI.TemplateParser.ProcessMainDirective(IDictionary mainDirective)
try to remove the ~ from the MasterPageFile="~/MasterPage.master" the tag inside the content page and if it still does not work, remove the / if they are "mater page and the content page" in the same root
http://forums.microsoft.com/technet/ShowPost.aspx?siteid=17&postid=2960550
ReplyDeleteadd this in web.cofig safemode section
ReplyDelete< PageParserPaths >
< PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
< /PageParserPaths>
Why not set the master page programmatically in the codebehind.
ReplyDeleteprotected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
this._myTeamSite =
SPControl.GetContextWeb(Context);
this.MasterPageFile =
_myTeamSite.MasterUrl;
}
this will ensure that you are using the correct master page. What if you customize your master page, and you are not using application.master anymore... it does no good to use a static master page. Just pull the master page that your stie is currently using that, and set the master page for you custom form to that. viola.
It's very easy See this..
ReplyDeletehttp://dotnetkeeda.blogspot.com/2009/04/sharing-master-pages-across-web.html
HI,
ReplyDeleteto execute this solution => (try to remove the ~ from the MasterPageFile="~/MasterPage.master" the tag inside the content page and if it still does not work, remove the / if they are "mater page and the content page" in the same root )
Where I will put this modification? which file?
on your new developed web page or the content page, there is a HTML tag for referencing the master page it looks like
DeleteMasterPageFile="~/MasterPage.master"
make it
MasterPageFile="/MasterPage.master"