English 中文(简体)
Sharepoint 2010 register control as safe through wsp
原标题:

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!

问题回答

Check for typos and version differences.

Did you activate the feature for the web app?

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>




相关问题
SharePoint Custom Web Part With Active Directory

I am currently working on a custom SharePoint web part (WSS 3.0, not MOSS) that will pull in information for all of the users in Active Directory to build an up to date employee directory. This web ...

ASP.NET webparts with Oracle 10g

Hi I would like to use webparts in ASP.NET website . Is there any support of webparts with Oracle 10g in ASP.NET. I am new in webparts. I don t know whether there is any provider available for ...

Getting List Item URL in Sharepoint 2007

I m creating a webpart that aggregates a load of content from different lists throughout our site collection what I can t workout is how to get the exact link to each item. All I seem to get back is {...

ASP.NET web parts - not stored in a cookie

Recently I was reading the MCTS ASP.NET 3.5 exam preparation book. I finished the lesson about web parts. The author said that user personalization is stored in a database and tracked by a cookie in a ...

how to create a web part to track page creation time

I am new to SharePoint Server 2007 Web Part, and I am using SharePoint Server 2007 on Windows Server 2008. I program using VSTS 2008 + C# + .Net 3.5. I want to create a simple web part which could ...

Allow user to change the default web part styles

I have a web part which uses many SharePoint controls like menu, SPGrid, tool bar etc. I want the user to be able to change the style by specifying an external CSS file. Can somebody tell me how I ...

Sharepoint 2007 Data view Webpart custom parameters

I m sort of new to the custom parameters that can be setup on a DataView Webpart. There are 6 options: - None - Control - Cookie - Form - QueryString - Server Variable I think that None, Cookie and ...

热门标签