Monday, June 8, 2009

MOSS: Code blocks are not allowed in this file


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.



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



No comments: