lunedì, dicembre 14, 2009

Using Server-Side Code with SharePoint

This may be old news to you, but I was just reading on Kirk Evan’s Blog on MSDN that SharePoint disables the ability to create server-side script by default. I’ve been wondering why I always get errors like: “An error occurred during the processing of /pages/test.aspx. Code blocks are not allowed in this file.” Here’s the solution from Kirk:

Hmm… yeah, code blocks are allowed in ASP.NET pages. What's going on? Oh yeah! 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:

<PageParserPaths>
  <PageParserPath VirtualPath="/pages/test.aspx" CompilationMode="Always" AllowServerSideScript="true" />
</PageParserPaths>