Remember the problems you had in SharePoint 2003 pages because it was not possible to plug in a simple piece of server side script in your pages? That you always had to write custom controls to accomplish this? Those times could be over, as longs as you approach this with great care.
In the web.config file in the SharePoint virtual directory contains the following section:
<SafeMode MaxControls="200" CallStack="false" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="false">
By default the node <PageParserPaths> is empty. You can add <PageParserPath> nodes to specify the virtual paths where you want to allow server side scripts:
<PageParserPath VirtualPath="/pages/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true"/>
Where CompilationMode is one of the following values:
|Always||The page should always be compiled (default value)|
|Auto||ASP.NET will not compile the page, if possible.|
|Never||The page or control should never be dynamically compiled.|
I assume that the AllowServerSideScript and IncludeSubFolders flags speak for themselves.
Be careful with the virtual paths you specify in your PageParserPaths. Anyone that can modify or add a page to the virtual path can insert code that will be executed server side with no restrictions.
A good location to specify as a PageParserPath is the location where you store your masterpages, for example /_catalogs/masterpage. You can now add server side script to your masterpages, which makes it available in all pages using this masterpage.
<PageParserPath VirtualPath="/_layouts/masterpage/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true"/>
There is no documentation available on this functionality. I found two references in the Microsoft SharePoint documentation that handled with variations: http://msdn.microsoft.com/en-us/library/ms562040.aspx and http://msdn.microsoft.com/en-us/library/ms551625.aspx.
Maurice Prather also describes the PageParserPath functionality in this blog post.