简体   繁体   中英

Code blocks are not allowed in custom master page in SharePoint 2013

I had migrated a SharePoint 2010 web application to SharePoint 2013 and running in compatible mode. i have a SharePoint designer modified master-page which is saved in content database. i had some inline codes running in master-page. the master page was working fine in SharePoint 2010. i had this line added in page parser

      <PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />

but in 2013 I still have the same line but it still gives me this error

An error occurred during the processing of /_catalogs/masterpage/custom.master. Code blocks are not allowed in this file.

when i change the entry in page parser to this it works fine

       <PageParserPath VirtualPath="/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />

which is not a good way as it opens all my pages to allow scripting.

any idea what is the change in 2013 and what is the best way to achieve this in 2013

here's my code:

<PageParserPath VirtualPath="~/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />

And it works fine on my end.

我通过将virtualpath设置为“〜/ _catalogs / masterpage / *”使其在2013年正常工作

Did you modify the master page in SharePoint 2010, or only in 2013?

This page: http://blog.bullseyeconsulting.com/archive/2013/03/21/fixing-code-blocks-not-allowed.aspx

Quoting:

As soon as it is "customized" (formerly known as "unghosted"), the reference to [the master page] for that site is in the database, not the file system. Without a change to web.config, code blocks are not allowed and the page breaks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM