SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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=, 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?

share|improve this question
up vote 0 down vote accepted

Two options here:

Create a separate WSP that only applies this safecontrol node.

This WSP would be crafted by hand (manually creating DDF file and running with makecab), as even WSPBuilder wouldn't handle this too well.

Another reason why Visual Studio 2010 isn't that great (it's automation is good but not very clever).

Use WebConfigModification

Follow the info here on how to modify web.config automatically from code (possibly from FeatureInstalled).

Personally I'd go for the second option, fewer WSPs = easier solution management overall.

share|improve this answer
Thx for the hint, i'll go with webConfigModification in a feature receiver – moi_meme Apr 7 '11 at 17:26

We use PowerShell to copy the web.config files in place when we deploy the WSP's and the web configs do include the safe controls that we want to have. We keep the config separate and in SVN so when the release is built this is added in separate and copied in separate along with the WSPS.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.