Thursday, 3 May 2012

SharePoint 2007: Code blocks are not allowed in this file

After editing a masterpage, or page layout you get the following error:

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




Solution:


1. open the web.config add the following code in <sharepoint> <safemode..>:

<SharePoint>
<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">
<PageParserPaths>
<PageParserPath VirtualPath="/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
</PageParserPaths>
</SafeMode>

....

2. Add the following safecontrol:

<SafeControl Src="~/_catalogs/masterpage/*" IncludeSubFolders="True" Safe="True" AllowRemoteDesigner="True" />


Good luck! :)

No comments: