Suddenly after a SharePoint solution deployment sites went down with this error message: "This page has encountered a critical error. Contact your system administrator if this problem persists."
To reveal the actual error, Enabled the stack trace and disabled the custom error attributes in web.config, Got this detailed error:
Line 1: <%@ Page Inherits="Microsoft.SharePoint.Publishing.TemplateRedirectionPage,Microsoft.SharePoint.Publishing,Version=18.104.22.168,Culture=neutral,PublicKeyToken=71e9bce111e9429c" %> <%@ Reference VirtualPath="~TemplatePageUrl" %>; <%@ Reference VirtualPath="~masterurl/custom.master" %> <html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"><head>Line 2: <!--[if gte mso 9]><xml>
Line 3: <mso:CustomDocumentProperties>
Additionally, In the event log there was a event logged related to this error: "Safe mode did not start successfully"
Usually, This error caused by wrong entries under <SafeControl> section in web.config. Remember, Web.config is case sensitive. Instead of "TypeName" if you place "typename" it could lead you to above error!!! Check for Invalid entries in web.config file in order to avoid this error.
Other possibility is: If the site template you are using is not registered as safe in web.config or the feature which you try to install does not register the safe entries may cause this issue.
- In my case, Restoring web.config from earlier backups solved this issue.
- If you don't have web.config (You are a bad SharePoint Administrator!) Take every entry out of <SafeControl> section, and try adding them one by one. Stop and find the culprit!
Getting WebPartPageUserException when adding webpart via SPLimitedWebPartManager?
SPLimitedWebPartManager loops through all the web parts available before adding a particular web part to the page. So, when you have any invalid/broken DLL's placed in Bin/GAC, you will get the error: "WebPartPageUserException: This page has encountered a critical error. Contact your system administrator if this problem persists."
Fix? Run the code in debug mode, look at the output window, and you will find which component is causing the problem. In my case, I just deleted it from bin folder and fixed the issue.
You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.