SharePoint 2013 Error Code blocks are not allowed in this file

SharePoint 2013 Error Code blocks are not allowed in this file
InfoPath alternatives for form designing SharePoint

In this post we will discuss how to resolve issue Code blocks are not allowed in this file which comes when you will try to run server side code in the SharePoint server. If you have created page using SharePoint designer 2013 and you have written code using <script runat=”server”>.

Also read:
– Deploy SharePoint 2013 designer workflow to different site in SharePoint 2013

– How to enable anonymous access in SharePoint 2013?

– add an app page showing loading sharepoint 2013

The error will comes as:

Server Error in ‘/’ Application.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Code blocks are not allowed in this file.

Parser Error Message: Code blocks are not allowed in this file.

SharePoint 2013 Error Code blocks are not allowed in this file
SharePoint 2013 Error Code blocks are not allowed in this file

Solution:
To resolve the issue, put the below entry in the web.config file under <PageParserPaths> </PageParserPaths>

<PageParserPath VirtualPath=”/Pages/MyTestAspxPage.aspx” CompilationMode=”Always” AllowServerSideScript=”true” IncludeSubFolders=”true” />

It looks like below:

<SafeMode MaxControls=”200″ CallStack=”true” DirectFileDependencies=”10″ TotalFileDependencies=”250″ AllowPageLevelTrace=”false”>
<PageParserPaths>
<PageParserPath VirtualPath=”/Pages/MyTestAspxPage.aspx” CompilationMode=”Always” AllowServerSideScript=”true” IncludeSubFolders=”true” />
</PageParserPaths>
</SafeMode>

Hope this will be helpful.

Similar SharePoint 2013 Tutorials

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →

Leave a Reply