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>
1 thought on “How to solve “Code blocks are not allowed in this file” error?”
I have read this solution on many blogs but it did not work for me. Am I determining the virtual path incorrectly? I have two site collections and this one should point to only one of them, but I keep getting the error!
Comments are closed.