Users report the following error when attempting to access a document library in SharePoint.
An error occurred during the processing of /site/SharedDocuments/Forms/AllItems.aspx. Code blocks are not allowed in this file.
Ever so often I have clients contact me with a SharePoint library fully corrupted reporting an error such as “Code blocks are not allowed in this file”. The error is, in fact, limited to a specific view but it’s usually the default view, therefore the error makes the library appear like it is completely inaccessible. The root cause of the error is simple – a user replaced a view file from the /forms/ folder of the document library, typically “AllItems.aspx” such as the screenshot below suggests. Typically this occurs when the user is using explorer view but I’ve heard of manifest presentations of this error as well.
Solution – Option 1
1) Open site that contains the library
2) Click on “Site Actions” >> “Site Settings” to view the site settings page “_layouts/settings.aspx”
3) Click on the library that displays the error to view the library’s settings page
4) Add a new view to the library and check the box “default view”
Solution – Option 2
In this solution, you are going to replace some of the files in the /forms/ directory of the document library. To do this open 2 document libraries in explorer view and navigate to the “forms” folder which is displayed partially grayed out (note that you may have to show hidden files in your client explorer). In the screenshot below I am replacing the corrupt file “AllItems.aspx” with the same file from another library.
*** If you do NOT know what explorer view is or how to open it then STOP, you should not be doing this.
Rating: 9.7/10 (14 votes cast)
Rating: +11 (from 15 votes)
SharePoint Error: Code blocks are not allowed in this file, 9.7 out of 10 based on 14 ratings
Ulysses Ludwig is a SharePoint architect with over 16 years in the IT and computer industry. Ulysses' primary focus is SharePoint but he dabbles in the latest web technologies and likes to develop software in his spare time.