EnjoySharePoint YouTube Channel

code blocks are not allowed in this file SharePoint 2013 search center site

In this post we will discuss 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 search center site default.aspx page.

Get Office 365 Enterprise E3 Or Business Premium Subscription & Try out all the features

You may also read:
PowerShell to know site created date SharePoint 2013

SharePoint 2016 new features

SharePoint 2013 Implement RunWithElevatedPrivileges with Apps(S2S)

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.

Troubleshoot issues with Microsoft SharePoint Foundation.
Correlation ID: e81c4a9d-7ea9-a03f-6251-c9c00b1ce67d

Date and Time: 12/10/2015 10:01:57 PM

Approach I tried:
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 occured.

What I feel here is if you have created the search center site by using “Basic Search Center” template then it gives this error.

Solution I tried: (Solution-1)
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 Open the default.aspx page using SharePoint designer 2013. The check out 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)
display: none;

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.

Hope this will be helpful.

Check out Best Alternative to InfoPath -> Try Now
You May Also like the Following SharePoint 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 →