Skip to content
Petkir Blog
XLinkedinBluesky

Not registered as a safe control Error after SharePoint On-Premise update

Code, SharePoint1 min read

What Happened

After applying the September 2024 SharePoint on-premise update, I encountered an error from a web part. The error indicated that the DLL was not registered as a safe control, which caused the web part to fail.

Analysis

The error message specifically mentioned that the control type Namespace.Type was not allowed on the page because it was not registered as a safe control in the web.config file. To resolve this, I first checked the web.config and confirmed that the Namespace was already registered as safe, and the type was set with a wildcard (*). I decided to explicitly register the type instead of using a wildcard, but the error persisted.

Let's start digging the uls log

Information: https://url - An unexpected error has occurred. Typ: Namespace.Type, Error: The type Namespace.Type... could not be found or it is not registered as safe

However, upon digging deeper, I discovered two additional log entries that were the key to solving the issue:

Log Entry 1:

Missed type in new allowlist. Type = Namespace.Type

Log Entry 2:

High Allowing ControlCompatMode=false object in ObjectFormatter. Type = Namespace.Type

These entries pointed to the fact that the control was not included in the new allowlist, and SharePoint was blocking the object because ControlCompatMode was set to false.

The Solution

To resolve the issue, I modified the web.config file, I updated the <SafeMode> section to ensure control compatibility by setting ControlCompatMode="true":

<SafeMode MaxControls="200" CallStack="false" ControlCompatMode="true" DirectFileDependencies="10" TotalFileDependencies="250" AllowPageLevelTrace="false">

By making these changes, the custom control was successfully allowed on the page, and the error was resolved.