第 4 步:部署自定义搜索 Web 部件

您在此演练中创建的自定义搜索 Web 部件不具有强名称,因此您不能将其部署到全局程序集缓存。您必须将其部署到网站的 _app_bin 目录。演练的第 4 步将介绍具体操作。

将自定义 Web 部件部署到您的网站

  1. 将 customSearchBDC.dll 复制到网站的 _app_bin 目录。其路径如下所示。

    \Inetpub\wwwroot\wss\VirtualDirectories\网站\_app_bin

    备注

    如果您不知道网站的应用程序路径,您可以在 Internet Services Manager 中进行验证。

  2. 如果您不知道网站的应用程序路径,您可以在 Internet Services Manager 中进行验证,具体操作如下:

    1. 打开 Internet Services Manager 控制台,展开网站节点,右键单击您网站的应用程序,然后单击“属性”。

    2. 单击“主目录”选项卡。“本地路径”字段中包含了应用程序的路径。

将自定义 Web 部件注册为 SafeControl

  1. 打开您要向其中添加自定义 Web 部件的网站的 web.config 文件。该文件位于网站的根文件夹中。

  2. 将以下 <SafeControl/> 标记添加到 web.config 的 <SafeControls> 部分:

    <SafeControl Assembly="customSearchBDC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Namespace=" customSearchBDC" TypeName="*" Safe="True" />
    
  3. 保存所做的更改,然后关闭 web.config 文件。

创建自定义 Web 部件的 .webpart 文件

  1. 在文本编辑器(如记事本)中打开一个新文件,然后向文件添加以下 XML 代码:

    <?xml version="1.0" encoding="utf-8"?>
    <webParts>
      <webPart xmlns="https://schemas.microsoft.com/WebPart/v3">
        <metaData>
         <type name="customSearchBDC.clsSearchProducts, customSearchBDC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          <importErrorMessage>Cannot import this Web Part.</importErrorMessage>
        </metaData>
        <data>
          <properties>
            <property name="Title" type="string">Custom BDC Search</property>
          </properties>
        </data>
      </webPart>
    </webParts>
    
  2. 将文件命名为“customSearchBDC.webpart”,然后将其保存。

    备注

    如果您没有使用 Office SharePoint Server 2007 服务器,那么若要完成此步骤,您必须将文件复制到一个 Office SharePoint Server 2007 服务器。

将自定义 Web 部件注册为 SafeControl

  1. 打开您要向其中添加自定义 Web 部件的网站的 web.config。

  2. 将以下 <SafeControl/> 标记添加到 web.config 文件的 <SafeControls> 部分:

    <SafeControl Assembly=" customSearchBDC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Namespace=" customSearchBDC" TypeName="*" Safe="True" />
    

将自定义 Web 部件部署到您的网站

  • 将 CustomSearchWebPart.dll 复制到网站的 _bin 目录。其路径如下所示。

    \Inetpub\wwwroot\wss\VirtualDirectories\网站

See Also

任务

演练:创建 AdventureWorks 业务数据应用程序示例的 ASP.NET Web 部件

步骤 1:为自定义搜索 Web 部件建立项目

步骤 2:为自定义搜索 Web 部件添加代码

步骤 3:创建 XSLT 转换代码

步骤 5:测试搜索 BDC Web 部件