This SharePoint tutorial explains, how to fix error code blocks are not allowed in this file which comes when you will try to run server-side code in the SharePoint 2013 server.
We will also see how to solve the same code blocks are not allowed in this file error which comes SharePoint 2013 search center site.
If you have created a page using SharePoint designer 2013 and you have written code using <script runat=”server”>.
The error will come 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.
SharePoint Tutorial Contents
To resolve the issue, but 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>
This is how we can solve error SharePoint 2013 error code blocks that are not allowed in this file.
Now, we will see, how to resolve the error An error occurred during the processing of /siteurl/searchcenter/default.aspx. Code blocks are not allowed in this file. which comes in the search center site default.aspx page.
Recently while working in a migration project, I found an error while trying to open a search center site. The error coming as:
Sorry, something went wrong
An error occurred during the processing of /siteurl/searchcenter/default.aspx. Code blocks are not allowed in this file.
TECHNICAL DETAILS
Troubleshoot issues with Microsoft SharePoint Foundation.
Correlation ID: e81c4a9d-7ea9-a03f-6251-c9c00b1ce67d
I have created another search center site by using the “Basic Search Center” template. That site opened and worked perfectly. But then I changed from seattle master page to my custom master page. Again the same error occurred.
What I feel here is if you have created the search center site by using the “Basic Search Center” template then it gives this error.
What I did is, I created another site by using the “Enterprise Search Center” template. This time it works for me and also it took my custom master page without any error. For me, this is the better solution I feel.
The other option you can try is to open the default.aspx page using SharePoint designer 2013. The checkout and edit the file in advanced mode. Now if you will open the page you can see the below code at the starting.
<SharePoint:StyleBlock runat="server">
<%
WebPartManager webPartManager = SPWebPartManager.GetCurrentWebPartManager(this.Page);
if (webPartManager != null && webPartManager.DisplayMode == SPWebPartManager.BrowseDisplayMode)
{
%>#s4-ribbonrow
{
display: none;
}
<%
}
%>
</SharePoint:StyleBlock>
Just remove the above StyleBlock from the Default.aspx page (Remember to take a backup of the file before removing). Save the page.
After refresh if it did not work, then just remove the search web part and add it again it will work.
You may like following SharePoint tutorials:
- Create a simple bootstrap navigation menu using content search web part in SharePoint 2013
- Create a web part page using visual studio 2013 in SharePoint 2013
- SharePoint Current user filter web part
- Remove duplicate web parts from the SharePoint web part page
- Show paging at top in list view web part in SharePoint 2013/2016/Online using jQuery
- How to Export and Import Web Part in SharePoint 2013 Online?
- SharePoint 2013 content search web part vs content query web part
This SharePoint tutorial explains, how to solve error code blocks are not allowed in this file in SharePoint 2013 or Online.
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 SPGuides.com