Parser Error Message: Code blocks are not allowed in this file.
Recieved this error when trying to add some code blocks into my sharepoint site, obviously Asp.NET pages can use code blocks so it had to be SharePoint blocking somehow.
Turns out SharePoint disables the ability to create server-side script by default, you have to turn it on. You do that in the web.config file, in the configuration/SharePoint/PageParserPaths configuration section add the following code making sure to amend the virtual paths as you see fit.
As you can see below I allow access to my masterpage directory to allow page layouts to use code blocks and the pages directory.
<PageParserPath VirtualPath="/_catalogs/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
<PageParserPath VirtualPath="/pages/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
That should now enable the code blocks within your aspx page.