Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

i have one portal for my student and been developed by vendor. so i dont have the coding. my problem is when i want to import my webparts into the portal, I need to insert safecontrol into the webconfig.

do you know the best way to do this since i dont have the code. I try to modify at virtual directory/webconfig but an error occurs. Please help.. many thanks

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

Another way is to add an additional webconfig.*.xml file into the 12/CONFIG folder with contents similar to the following

<?xml version="1.0" encoding="utf-8" ?>
<actions>
  <add path="configuration/SharePoint/SafeControls">
    <SafeControl
      Assembly="My.Assembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0000000000000000"
      Namespace="My.Assembly"
      TypeName="TypeToMakeSafe"
      Safe="True" />
  </add>
</actions>

These files are read by SharePoint automatically to create the web.config file, and is the recommended way of making alterations to web.config.

share|improve this answer
    
u means i add another webconfig file.. so it's redundance? i afraid to try because the portal currently life. if you said it's true then i will try it.. thanks Tim :) –  Tasha Apr 26 '11 at 7:44
    
placed it here (%ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14) or (C:\inetpub\wwwroot\wss\VirtualDirectories\80) –  Tasha Apr 26 '11 at 8:19
    
You add it into the CONFIG folder in the SharePoint Root location, with a name like webconfig.tasha.xml - it then creates the Web.config file correctly for you. –  Tim Ebenezer May 3 '11 at 14:10
    
Thanks everyone :) –  Tasha May 12 '11 at 1:39
add comment

You can either add the safecontrol entry manually (which you tried, please share your error) or programmatically using your own code, which is the preferred way.

For details see this article.

share|improve this answer
    
thanks guys.. im new to sharepoint.. actually i follow that tutorial Manually editing the web.config (bad).. the error display. "an error occurs, please contact your administrator for details" any other way.. this is my safecontrol <SafeControl Assembly="Uniten.Alumni.Webparts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3806e03bf81edc95" Namespace="Uniten.Alumni.Webparts" TypeName="" Safe="True" /> <SafeControl Assembly="Alumni, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6f36473742dd2ae4" Namespace="Alumni" TypeName="" Safe="True" SafeAgainstScript="False" /> –  Tasha Apr 26 '11 at 7:40
    
Actually we do this with additions to the web.config file, since we have a lot of customizations we keep those files in SVN and deploy them with the WSP's. I'm not an advocate for manually making changes to config files, but in some cases it is a solution. –  MichaelF Apr 26 '11 at 11:57
    
Programmatically is not the preferred way I'm afraid, see answer above. –  Tim Ebenezer May 12 '11 at 8:37
    
The details escape me, but we decided against this at the time as the entries in the web.config are not cleaned up after an uninstallation of the software. Or at least not in the version of SharePoint we tested at the time. –  Muhimbi May 12 '11 at 10:47
add comment

Your Answer

 
discard

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.