in

DotNetDeveloper

Bits o this Bits o that

SharePoint

October 2008 - Posts

  • Code blocks are not allowed in this file

    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.

DotNetDeveloper.co.uk
Powered by Community Server (Non-Commercial Edition), by Telligent Systems