Sharepoint 2010 register control as safe through w

2019-05-14 17:00发布

I created a "Hello World" Sharepoint 2010 solution using VS2010. It contains just a feature, and a webpart containing a label. I registered the webpart as a safe control in the "Properties" window of the webpart, in VS2010.

When I deploy my solution to my local server, everything works great! I can add the webpart to a page, and in the web.config file my control is added to the SafeControls list. When I install the same solution on a different server, I can see the webpart in the list of available webparts, but when I try to add it to the page, it tells me that it's not registered as safe. When I check the web.config file, there is no entry for my control. If I add one manually (the one from my dev server), things start to work.

Now, I wonder why the control is not registered when I install the wsp file. The manifest inside the wsp contains this line:

<Assemblies>
<Assembly Location="abc.TestWebPart.dll" DeploymentTarget="GlobalAssemblyCache">
  <SafeControls>
    <SafeControl Assembly="abc.TestWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e262c75e6f6e8440" Namespace="abc.TestWebPart.VisualWebPart1" TypeName="*" />
  </SafeControls>
</Assembly>

Any ideas are very welcomed!

3条回答
三岁会撩人
2楼-- · 2019-05-14 17:18

Late answer I know.

I think you are missing ' Safe="TRUE" ' in your SafeControl Tag.

Correct code:

<Assemblies>
  <Assembly Location="abc.TestWebPart.dll" DeploymentTarget="GlobalAssemblyCache">
    <SafeControls>
      <SafeControl 
        Assembly="abc.TestWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e262c75e6f6e8440" 
        Namespace="abc.TestWebPart.VisualWebPart1" 
        TypeName="*"
        Safe="TRUE" 
      />
    </SafeControls>
  </Assembly>
</Assemblies>
查看更多
劳资没心,怎么记你
3楼-- · 2019-05-14 17:38

Did you activate the feature for the web app?

查看更多
不美不萌又怎样
4楼-- · 2019-05-14 17:42

Check for typos and version differences.

查看更多
登录 后发表回答