Under what circumstances is a safe control entry necessary? All the examples on internet talk about creating a visual webpart project, signing dll, adding safecontrol entry and then adding to masterpage. I have a sitdefinition solution which has a few projects. One project has a visual webpart and visual studio automatically added safecontrol entry in web.config. I have a usercontrol which i would like to place on masterpage but I cant find the safecontrol options in the properties panel and I was able to deploy the wsp and also put the usercontrol on the masterpage without any error about "type not being safe". Under what circumstances is a safe control entry necessary?Do all webparts built by user have to be registered as safecontrol? Is it required in this instance and how do i do it if required?
1 Answer
For security, SharePoint differentiates between Web controls that are protected against script injection and Web controls that are not. Protected controls, or safe controls, can be accessed by untrusted users.
Also check this link for more details
-
Hi thanks.But what I wanted to know is 1)do only visual webparts,usercontrols with server side code need to be registered as safecontrol or is there anything else? 2) In my case, the user control on masterpage is not registered as safecontrol but it still works. 3) So I am confused and wanted to know under what circumstances is adding the safecontrol necessary. 4)Is it necessary in my scenario? Commented May 20, 2014 at 5:36
-
1For user controls its not required but for visual web parts it is required.– AanchalCommented May 20, 2014 at 5:39
-
Ok, thanks for the clarification that safe controls are meant for visual webparts only.On the internet, a few examples talk about adding safe control manually for visual webpart or adding it through properties window.But in my case, visual studio added this automatically for my visual webpart.So when does adding manually ever come in? Commented May 20, 2014 at 5:52
-
1There is some settings in visual studio to add automatically to web.congif. In your case it would be true.– AanchalCommented May 20, 2014 at 5:55