Freigeben über


Updating “safecontrol” entries after a namespace rename for web part

Body:

I have had couple of developers tell me the steps they take to update the safecontrol entry in web.config to avoid the dreaded “Type not registered as safe” error after renaming the namespace, which really prompted me to write this post

By default when you add a web part to your SharePoint project in Visual Studio, VS creates a folder under your project in file system to store all web part files, if you look at web part’s code behind file the namespace will contain the folder name by default. So for example if the core namespace for your web part library “contoso.sharepoint.webparts” and let’s say you added a “StockWebPart” to show stock quotes, namespace for your web part code behind will say “contoso.sharepoint.webparts.stockwebpart” also the full type name for stock web part will look like “contoso.sharepoint.webparts.stockwebpart.stockwebpart”

So to keep things clean and you are a good SharePoint developer when you rename the namespace. There is an easier way to update the Safe Control entries from Visual Studio.

If you click on the web part item in VS in properties window you will notice an option called Safe Control Entries

safecontrol1

If you click on the “..” button this will bring up a dialog where you can update the safe control entries that will be written on to the web.config. See image below

safecontrol2

That’s about it

This just seems like reverse of making SharePoint developers productive using Visual Studio

Hope that helps

Cheers,

</Ram>

Technorati Tags: SharePoint2010

Published: 9/1/2011 6:13 PM

Attachments: https://www.spmcm.me/Blog/Lists/Posts/Attachments/43/safecontrol1_6_48CCC1F5.png
https://www.spmcm.me/Blog/Lists/Posts/Attachments/43/safecontrol1_thumb_2_48CCC1F5.png
https://www.spmcm.me/Blog/Lists/Posts/Attachments/43/safecontrol2_8_48CCC1F5.png
https://www.spmcm.me/Blog/Lists/Posts/Attachments/43/safecontrol2_thumb_3_48CCC1F5.png