Add ContentEditorWebPart to the list of Safe Controls

674 views Asked by At

I need to add the ContentEditorWebPart in the list of SafeControls because of this. Unless there's a better way...

The problem is, I don't want to add it manually, i want to do this automatically when I deplou my solution.

So I tried adding my safe control to the .spdata of the module requiring this, like this:

<SafeControls>
    <SafeControl Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Namespace="Microsoft.SharePoint.WebPartPages" TypeName="ContentEditorWebPart" Safe="True" />
</SafeControls>

but when I check my web.config, it changes the assembly to my projects assembly..

And if I add it to my package, i have to deploy the Sarepoint dll with it.

So What is the best way to add it to the SafeControls?

2

There are 2 answers

0
moi_meme On BEST ANSWER

For the record, I've decided to add a feature receiver which is gonna use SPWebConfigModification to add the safe control too the web.config

for details see How to: Add and Remove Web.config Settings Programmatically

0
gdbdable On

Using of SPWebConfigModification in this case is redurantly. This functionality can be archived by editing file Package.Template.Xml:

<?xml version="1.0" encoding="utf-8"?>
<Solution xmlns="http://schemas.microsoft.com/sharepoint/">
<Assemblies>
  <Assembly Location="Telerik.Web.UI.dll" DeploymentTarget="GlobalAssemblyCache">
    <SafeControls>
      <SafeControl Assembly="Telerik.Web.UI, Version=2012.2.912.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TypeName="*" Safe="True" SafeAgainstScript="False" />
    </SafeControls>
  </Assembly>
</Assemblies>
</Solution>

In this case I add assembly Telerik.Web.UI.dll in safe controls of web.config