Navigation

Search

Categories

On this page

Code-blocks are not allowed in this file: Using Server-Side Code with SharePoint

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 112
This Year: 50
This Month: 0
This Week: 0
Comments: 0

Sign In

 Thursday, October 04, 2007
Thursday, October 04, 2007 12:32:55 PM (Eastern Standard Time, UTC-05:00) ( )

I've started using Sharepoint at work and although I've been coding in ASP.NET a couple of years, I'm finding the learning curve a little steep. 

If you use the Microsoft Office SharePoint Designer to add a new page to your site, you will see that it looks just like any other ASP.NET page.  However, if you try an add an inline code block using the standard

<script></script>

tags, you'll receive an error similar to this one:  "An error occurred during the processing of /Pages/test.aspx. Code blocks are not allowed in this file."

Hmm… yeah, code blocks are allowed in ASP.NET pages. 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>

By the way, there are multiple web.config files and the one you should edit is C:\Inetpub\wwwroot\wss\VirtualDirectories\80\web.config