Home | Web Design and iOS Development

Registering web parts as 'safe' (SharePoint)

If you get a message like:
 
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: The control type 'VSeWSS.TestPart.TestPart' is not allowed on this page. The type is not registered as safe.
Source Error:

Line 40:   <WebPartPages:WebPartZone id="g_1F019885B90B4FA0A7D65ABBDFF9F391" runat="server" title="Zone 1">
Line 41:   </WebPartPages:WebPartZone> 
Line 42: <TestPart:TestPart runat="server" ID="TestPart1" Description="TestPart Description" Title="TestPart Web Part" ImportErrorMessage="Cannot import TestPart Web Part." __MarkupType="vsattributemarkup" __WebPartId="{aff2c1dc-9e98-43af-ab20-c9db07f9390e}" WebPart="true" __designer:IsClosed="false"></TestPart:TestPart> 
Line 43:   <PublishingWebControls:RichHtmlField id="_homePageBlock1" FieldName="ContentPH1"  runat="server"  AllowImages=False PopupEditorMode="True"/>
Line 44:  </div>
 

You need to go to the web.config file for that site collection (in C:\Inetpub\wwwroot\wss\VirtualDirectories) and amend the <safecontrols> section of the file. In this case it would be:
 
<SafeControl Assembly="TestPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5" Namespace="VSeWSS.TestPart" TypeName="TestPart" Safe="True" />