I know this question has been raised before a lot of people, and I have seriously looked at their responses, but no one can solve my problem.

I created a custom web part use default name and namespace. The web part are also automatically deployed. When it was added on the page , I got a messages like 'A Web Part or Web Form Control on this Page cannot be displayed or imported. The type is not registered as safe.' It have not been solved until now.

My production steps are as follows:

1.Open VS2010 --New project --C# --Sharepoint --2010 --VisualWebPart All the things is default.

2.Add a Lable and a Button in Design mode. When the button is pressed, the lable shows' hello'.

3.Add '[assembly: AllowPartiallyTrustedCallers()]' to the AssemblyInfo.cs

4.Compile and deploy the files. right-click the solution name and click the Build and Deploy.

5.make sure the Web.Config and 'SharePointProjectItem.spdata' have the same config on namespace.

6.open the site , open the page. insert a my web part. And I got the message.I'm not sure my steps are correct, but I really want to know how to solve this problem.

2 Answers 2


I assume you renamed the webpart or changed the namespace in a not consistent way.

Go try the following:

  1. Create a new project.
  2. Add a visual webpart
  3. Deploy it
  4. Add it to a page

If you have the same error something is definitely wrong. If no error, you changed something in a non consistent way (e.g. renaming namespace). The default SharePoint template works without changing AssemblyInfo, web.config (bad idea to change it manually) or spdata files.


You have to add "SafeControl" element under "SafeControls" element to web.config of that web application.


<SafeControl Assembly="Assembly name, Version=, Culture=neutral,     PublicKeyToken=d8eb6481d8b4beec" Namespace="your functionality's namespace" TypeName="*" Safe="True"/>
  • I'm sure this is already inside.But it seems not very useful.
    – seven yang
    Nov 15, 2013 at 8:25
  • Manually editing the web.config is a BAD idea. Dont do it. Nov 15, 2013 at 9:15
  • You can add and look at a safe control element from the webparts properties too; Select the webpart in VS, look in the properties pane for Safe Control entries, click the three dots next to the word "(Collection)" Nov 15, 2013 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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