Monday, June 8, 2009

MOSS: Code blocks are not allowed in this file

Hey...

When you try to add a server side code for an aspx page in your document library with the help of share point designer. you might get the following error when you try to view the page.

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

The reason is that Sharepoint by default disables server side code (code behind) for an aspx page. The Solution is we need to add the path of the page as exception in web.config.

Solution:

<PageParserPaths>

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

</PageParserPaths>


Regards
Fauzi

No comments: