One of the great features of SharePoint is that it is built on-top of .Net, thus allowing nearly unlimited modifications via additional code. Most of the time this additional functionality would be added via Web Parts, features, etc, but sometimes it would be nice to add inline code to a specific SharePoint managed aspx page. But by default SharePoint does not allow code blocks in .aspx pages.
To enable code blocks in this file, on the server you need to open this site’s web.config file, by default found in c:inetpubwwwrootwssVirtualDirectories”sitedirectory”, and look for the following code block: PageParserPaths
By default the <PageParserPaths> section is blank. All you need to so is add the following to the <PageParserPaths> section:
<PageParserPath VirtualPath=”/*” CompilationMode=”Always” AllowServerSideScript=”true” IncludeSubFolders=”true” />
Also, is it possible to configure this for a particular path in the virtual path value, i.e. VirtualPage=”/Pages/*”. In addition to that, there are three values for CompliationMode:
Always: (this is the default value): Always compile this page
Auto: SharePoint will not compile the page if possible
Never: This page should never be compiled
AllowServerSideScript can be set to true or false. In this case it must be true.
Once this modifications are done, save the web.config file and your page should now load.
Hope it helps!