Wednesday, March 14, 2007

If you add inline code to your e.g. PageLayout in MOSS 2007 you will get the following error: "Code blocks are not allowed in this file".

To avoid this problem, add the following code block to your web.config:

<PageParserPaths>

  <PageParserPath VirtualPath="/" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />

</PageParserPaths>

This will allow inline code in your entire site collection. Make sure to be aware with security issues and inline code. To enable inline code only for a single file use:

<PageParserPaths>

  <PageParserPath VirtualPath="/Pages/MyPage.aspx" CompilationMode="Always" AllowServerSideScript="true" />

</PageParserPaths>