配置WebPart

一)注册你的Web Part 作为一个SafeControl

作为一个安全办法,Windows SharePoint Services 要求你在Web.Config文件中注册Web Part’s assemblynamespace作为一个Safecontrol

下面将一个WebPart Assembly注册成一个SafeControl,编辑c:"inetpub"wwwroot"web.config文件,将下面的节点填加到<SafeControls>块中。
格式说明:
<!--

SafeControl Attributes:

    Assembly="[Assembly]" - The .NET assembly in which the control is contained. This attribute can also contain version, culture,_u97 ?nd public key token information.

    Namespace="[Namespace]" - The .NET namespace in which the control is defined.                                        

    TypeName="[Typename]" - The .NET class name of the control. You can type an asterisk (*) wildcard character to indicate all TypeNames in a Namespace.

    Safe="[True|False]" - Specifies whether a Web Part or Web Form Control is safe and can be displayed on a Web Parts Page. This attribute is True by default.

-->

<SafeControl

   Assembly="SimpleWebPart, Version=1.0.0.0, Culture=neutral, PublicKeyToken=def148956c61a16b"

   Namespace="MyWebParts"

   TypeName="*"

   Safe="True"

/>

注意:将你的Web Part’s assembly.替换为PublicKeyToken的值,要正确获得这个值,请使用sn.exe命令。

sn.exe -T c:"inetpub"wwwroot"bin"SimpleWebPart.dll

除了这种办法,还有一种就是将你的Assembly拷备到GAC下,查看它的属性,也能获得。

posted @ 2008-05-16 16:34  ChoiceShan  阅读(122)  评论(0编辑  收藏  举报