How to solve “Code blocks are not allowed in this file” error?
By namwar - Last updated: Monday, August 9, 2010 - Save & Share - Leave a Comment
Hi,
if you are getting “Code blocks are not allowed in this file” error while browsing a page in SharePoint then it is because SharePoint disables the server code in script block. This is to make sure that no one should just upload an aspx page with malicious server side code and execute it to kill the SharePoint server
:)
OK, got it….now tell me how to allow server code in a specific page?
Here you go, just add following PageParserPath nodes under PageParserPaths node. Refer below for an example:
<PageParserPaths>
<!-- Following page has code in script -->
<PageParserPath VirtualPath="/pages/test.aspx" CompilationMode="Always" AllowServerSideScript="true" />
</PageParserPaths>