Step 4: Deploy the Custom Search Web Part

The custom search Web Part you create in this walkthrough is not strong-named, so you cannot deploy it to the global assembly cache. You must deploy it to the _app_bin directory for your site. Step 4 of the walkthrough describes how to do this.

To deploy the custom Web Part to your site

  1. Copy customSearchBDC.dll to your site's _app_bin directory. The path will resemble the following.

    \Inetpub\wwwroot\wss\VirtualDirectories\Site\_app_bin

    Note

    If you do not know the application path for your site, you can verify this in Internet Services Manager.

  2. If you do not know the application path for your site, you can verify this in Internet Services Manager by doing the following:

    1. Open the Internet Services Manager console, expand the Web Sites node, right-click the application for your site, and then click Properties.

    2. Click the Home Directory tab. The Local path field contains the path to the application.

To register the custom Web Part as a SafeControl

  1. Open the web.config file for the site you want to add the custom Web Part to. You can find this file in the root folder for the site.

  2. Add the following <SafeControl/> tag to the <SafeControls> section of the web.config:

    <SafeControl Assembly="customSearchBDC, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" Namespace=" customSearchBDC" TypeName="*" Safe="True" />
    
  3. Save your changes, and then close the web.config file.

To create the .webpart file for the custom Web Part

  1. Open a new file in a text editor such as Notepad, and add the following XML code to the file:

    <?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. Name the file customSearchBDC.webpart, and then save it.

    Note

    If you are not working on the Office SharePoint Server 2007 server, then to complete this step you must copy the file to an Office SharePoint Server 2007 server.

To register the custom Web Part as a SafeControl

  1. Open the web.config for the site you want to add the custom Web Part to.

  2. Add the following <SafeControl/> tag to the <SafeControls> section of the web.config file.

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

To deploy the custom Web Part to your site

  • Copy CustomSearchWebPart.dll to your site's _bin directory. The path will resemble the following.

    \Inetpub\wwwroot\wss\VirtualDirectories\Site

See Also

Tasks

Walkthrough: Creating an ASP.NET Web Part for the AdventureWorks Business Data Application Sample
Step 1: Set Up the Project for the Custom Search Web Part
Step 2: Add the Code for the Custom Search Web Part
Step 3: Create the XSLT Transformation Code
Step 5: Testing the Search BDC Web Part