Code blocks are not allowed by default

While trying to add some code directly into a page using SharePoint Designer I realised that SharePoint disables the ability to create server-side script by default, and the code gets stripped out when I save the file.  The error reads:

An error occurred during the processing of /SitePages/test.aspx.  Code blocks are not allowed in this file.

After a bit of research I discovered that this is really easy to fix with one line in the web.config file.  This is an example of the configuration required, the path will change depending upon the location of the files:

<PageParserPaths>
   <PageParserPath VirtualPath=”/SitePages/*” CompilationMode=”Always” AllowServerSideScript=”True” />
</PageParserPaths>

Note: The web.config file is located in c:\inetpub\wwwroot\wss\VirtualDirectories\80 and will need to be edited on each server if you have more than one web front end.  Also be cautious of using wildcards to allow any page in a folder to include scripts.

[BlogBookmark] [Blogsvine] [del.icio.us] [Digg] [Facebook] [Furl] [Google] [LinkedIn] [MySpace] [Reddit] [Slashdot] [StumbleUpon] [Twitter] [Windows Live] [Yahoo!] [Email]