If you come accross this error, here is the information you need to solve it:
Cause: you are running code snippets inside a file that is not allowed to do so by default.
Afected files: i.e. Master pages and Page layouts
Solution: you have to add an explicit authorization for the file(s) where you want to do so. The question is: do you really want to do it? You should take the best approach which is to add a code behind file (you can find how to do it here: Adding Code-Behind Files to Master Pages and Page Layouts in SharePoint Server 2007). If you still want to do it, just add a tag like this to your <PageParserPaths>:
<PageParserPath VirtualPath=”/_catalogs/masterpage/MyMaster.Master” CompilationMode=”Always” AllowServerSideScript=”true” />
Keep having fun 🙂
[…] https://mystepstones.wordpress.com/2009/02/13/code-blocks-are-not-allowed-in-this-file/ […]
[…] but I got an error which said “Code blocks are not allowed in this file”. I found this blogpost which explains the reason for this error. To fix this, I need to add a line to the […]