I'm getting this error on a copy of our SharePoint 2013 site collection. I've tried unghosting searchresults.aspx, but it comes back with "Cannot revert to the site definition version of this file. It is a custom file and is not part of the site definition".
4 Answers
I am currently having the same issue with my 2013 search site. here is the article helped me.
I was still having the same error after following the article above. I have added the line below in the web.config
<PageParserPath VirtualPath="/*" CompilationMode="Always" AllowServerSideScript="true" IncludeSubFolders="true" />
After this, the error has disapeared. This is not a very good solution because it is allowing all pages to run server side scripts.
You can use this to limit the pages VirtualPath="~/_catalogs/masterpage/*"
-
In my case I was creating a new basic search center site from scratch. When I tried Enterprise Search Center I did not have this problem :)– AslanCommented Jul 31, 2015 at 20:52
-
This didn't work for me:
VirtualPath="~/_catalogs/masterpage/*"
– PeterXCommented Oct 27, 2015 at 2:48 -
In SharePoint 2016 the wildcard approach is all that worked, exactly as it is written in the solution. Make sure to include the "IncludeSubFolders" attribute– philCommented Sep 12, 2016 at 21:48
As soon as it is "customized" (formerly known as "unghosted"), the reference to [the master page] for that site is in the database, not the file system. Without a change to web.config, code blocks are not allowed.
SharePoint disables the ability to create server-side script by default, you have to turn it on. You do that in the web.config file, in the configuration/SharePoint/PageParserPaths configuration section:
<PageParserPaths>
<PageParserPath VirtualPath="/pages/test.aspx" CompilationMode="Always" AllowServerSideScript="true" />
</PageParserPaths>
Code-blocks are not allowed in this file: Using Server-Side Code with SharePoint
-
1I'm still facing same issue even also i had specified above tag in web.config– LightCommented Jul 21, 2015 at 9:29
-
The VirtualPath in this example should be the path to your custom master page that is giving the error. e.g. /_catalogs/masterpage/mycustom.master Commented Mar 18, 2016 at 15:37
If there is a blue mark before your SearchResults.aspx,right click on it and click'Reset to Site Definition'
-
2This does not answer the question as per the StackExchange standards. Please check How to Answer. One-liners can be mentioned in a comment. Commented Feb 23, 2016 at 10:22
Tried both specific and wild card both did not work for me. What make it work was to reset the page to site definition.