Add Safe Control Entries to SharePoint 2010 Web Parts using VS2010

I was reviewing a SharePoint solution and found that a web part inside that solution has poor naming conventions so I decide to rename the web parts for giving the proper names to them.

I changed the necessary references in different files of web part (I’ll mention them in a separate blog post). Now after renaming the web part I deployed it on site and then tried to add it in a web part page and it simply throws me the error.

Type is not registered as safe“. Well at first glance I decided to see me safe controls entries inside my site’s web.config file and I was right that namespace part was wrong in web.config file. It was pointing to earlier namespace and class name. Humnnnn so if I changed this entry manually then it works fine but I need to automate the deployment process and I wanted to write the correct safe controls entries inside web.config whenever we deploy the web part. Well so question arises where to set my safe control entries inside my SharePoint solution. Well after analysing that I came to the solution. So below are the steps described for that:

1. Open your SharePoint web part project inside visual studio 2010.

2. Select the web part folder for which you want to change the safe control entries in web.config file.

3. Press F4 to open properties window (I am not talking here for property page.).

4. In properties windows there is last entry of properties displaying as “Safe Control Entries

5. Click on the eclipse sign in front of “Safe Control Entries” value.

6. Inside “Safe Control Entries” pop up window, check for Namespace properties inside SafeControlEntry1 properties panel.

7. Change value of namespace property according to your namespace and class and click ok.

8. Save and build the solution and deploy it again.

9. Now after successful deployment check web.config of site and voilà you’ll find the correct safe type entries of your web part.

Happy Share Pointing J

Microsoft made the excellent integration of SharePoint with Visual Studio 2010. Good to see that.

In my next blogs I’ll come with these types of enhancements that visual studio provides for SharePoint 2010.

Advertisement

4 Comments (+add yours?)

  1. Trackback: Web Parts | Web Hosting Information and Tips
  2. apple ipad app reviews
    Oct 15, 2011 @ 12:29:39

    Oh my goodness! an incredible write-up dude. Thank you Even so My business is experiencing dilemma with ur rss . Don’t know why Unable to subscribe to it. Can there be anyone obtaining identical rss difficulty? Anybody who knows kindly respond. Thnkx

    Reply

  3. book lists
    Oct 17, 2011 @ 10:24:46

    What a great blog! This post has a lot of interesting information! Would you mind leaving me a couple suggestions for my site?

    Reply

  4. writing advice
    Oct 19, 2011 @ 11:24:49

    What a great blog! This post has a lot of interesting information! Would you mind leaving me a couple suggestions for my site?

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 27 other followers