How to: Deploy Modules

Retired Content

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies.
This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

This topic describes how to deploy Web client application modules to a Web site. For information about modules, see Modules.

Prerequisites

This topic assumes that you have created and deployed an existing Web client solution. This topic describes how to deploy a new module to the Web site. For information about how to create a Web client solution, see How to: Create a Web Client Solution. For information about how to create modules, see How to: Create a Business Module and How to: Create a Foundational Module.

Deploying Modules Individually

You can independently deploy modules to a Web site. To do this, you use XCopy deployment. There are three types of files that comprise a module's deployment unit:

  • Module Web pages. These are ASP.NET Web pages that are displayed for your module. (Only business modules contain Web pages.)
  • Module assembly. This is a class library that contains the logic for your module.
  • Web.config file. This is an ASP.NET configuration file that contains the module definition. The module definition is a <module> entry inside the <modules> configuration section of the Composite Web Application Block. A module definition has the following elements:
    • name attribute. This is the name of the module.
    • assemblyName attribute. This is the name of the module assembly.
    • virtualPath attribute. This is the relative path where the Web pages of the module are located within the Web site. Business modules must always declare the attribute. Foundational modules must not declare the attribute.
    • <dependencies> element. This defines inter-module dependencies. A module can express dependencies on other modules by adding <dependency> entries inside the <dependencies> element. All modules listed as dependencies will be loaded before the current module is loaded.

For modules that you create as sub-Web application projects, the deployment unit also includes an additional file:

  • Module.Web assembly. This is a class library that contains the compiled Web site code (for example, the code-behind files for your Web pages).

A module can have a separate Web.config file, or you can add the module definition to the Web site Web.config file.

The following code shows an example of a single business module definition that has a dependency on the Shell module.

<module name="Module1" assemblyName="Module1" virtualPath="~/Module1">
  <dependencies>
    <dependency module="Shell" />
  </dependencies>
</module>

The following procedure describes how to deploy a module to a Web site by using XCopy and the ASP.NET default compilation (with ASP.NET default compilation, you copy the Web pages with the code-behind files to the production server and they are compiled dynamically when users first request a page).

To deploy a module to a Web site by using the ASP.NET default compilation and XCopy

  1. Copy the module's assembly to the Bin folder of the Web site.

    Note

    Note: Modifying the content of the Bin folder when the Web application is running will cause ASP.NET to restart the application.

  2. Create a folder for the module in the Web site and copy the module's ASP.NET Web pages, including the code behind files, to this folder.

  3. If the module has a separate Web.config file, copy the Web.config file to the folder that contains the module's Web pages. If the module does not have a separate Web.config file, add the module definition to the Web site Web.config file. For more information about how to add a module definition to a Web site Web.config file, see the section To add a module definition to the Web site Web.config file.

    Note

    Note: Modifying the Web site Web.config file while the application is running will cause ASP.NET to restart the application.

When you create a module as a sub-Web application project, the code-behind files for the module’s Web page are compiled into an assembly. The following procedure describes how to use XCopy to deploy a module created as a sub-Web application project.

To use XCopy to deploy a module created as a sub-Web application project

  1. Copy the following assemblies to the Bin folder of the Web site:
    • The module assembly (for example, Sales.dll)
    • The sub-Web application project assembly (for example, Sales.Web.dll)
  2. Create a folder for the module in the Web site and copy the module's ASP.NET Web pages to this folder.
  3. Copy the Web.config file to the folder that contains the module's Web pages. If the module does not have a separate Web.config file, add the module definition to the Web site Web.config file.

The following procedure describes how to use XCopy to deploy a module to a Web site by using ASP.NET pre-compilation (with ASP.NET pre-compilation, you pre-compile the Web site and deploy the compiled files to the production server with no code behind files).

To deploy a module to a Web site by using ASP.NET pre-compilation and XCopy

  1. Pre-compile the Web site and store the output in a location different than the production Web site location. For more information about how to pre-compile a Web site using the ASP.NET Compilation Tool (aspnet_compiler.exe), see How to: Pre-compile ASP.NET Web Sites for Deployment. For more information about how to pre-compile a Web site by using the Publish Web Site utility that integrates with Visual Web Developer, see Publishing Web Sites.

  2. Copy the module's assembly to the Bin folder of the production Web site.

    Note

    Note: Modifying the content of the Bin folder when the Web application is running will cause ASP.NET to restart the application.

  3. Create a folder for the module in the production Web site and copy the pre-compiled module's ASP.NET Web pages to this folder.

  4. Copy the pre-compiled assemblies of the module’s Web pages to the Bin folder of the production Web site.

    Note

    Note:If you are pre-compiling for deployment only (with non-updateable UI), you must also copy the .compiled files to the Bin folder of the production Web site.

  5. If the module has a separate Web.config file, copy the Web.config file to the folder that contains the module's Web pages. If the module does not have a separate Web.config file, add the module definition to the Web site Web.config file. For more information about how to add a module definition to a Web site Web.config file, see the section, To add a module definition to the Web site Web.config file.

    Note

    Note: Modifying the Web site Web.config file while the application is running causes ASP.NET to restart the application.

The following procedure describes how to add a module definition to the Web site Web.config file.

To add a module definition to the Web site Web.config file

  1. Open the Web site Web.config file.

  2. Locate the modules section inside the compositeWeb configuration section. The following code shows a modules section with the definition for the Shell module.

    <compositeWeb>
      <modules>
        <module name="Shell" assemblyName="Shell" virtualPath="~/" />    
      </modules>
    </compositeWeb>
    
  3. Add the module definition to the modules section. As an example, the following XML contains the module definition for three modules: a business module named Shell, a foundational module named FoundationalModule1, and a business module named BusinessModule1. BusinessModule 1 has a dependency on the Shell module.

    <compositeWeb>
      <modules>
        <module name="Shell" assemblyName="Shell" virtualPath="~/" />
        <module name="FoundationalModule1" assemblyName="FoundationalModule1" />
        <module name="BusinessModule1" assemblyName="BusinessModule1" virtualPath="~/BusinessModule1">
          <dependencies>
            <dependency module="Shell" />
          </dependencies>
        </module>
      </modules>
    </compositeWeb>
    

Outcome

Your Web site will have the following elements:

  • A Web site folder for the module; the folder contains the module's Web pages
  • The module assembly in the Bin folder of the Web site
  • A Web.config file in the module's folder (if you choose to use a centralized configuration, you will instead have a new module definition in the Web site Web.config file)
  • The assembly (single, if you create a sub-Web application project for module) or assemblies (multiple, if you use ASP.NET pre-compilation) for the Web pages in the Bin folder of the Web site.

Figure 1 illustrates a module deployment example.

Ff709893.2c03cf36-9605-42e0-b3cb-09226fcb93d5(en-us,PandP.10).png

Figure 1

Module deployment example

Related Information

For more information about ASP.NET pre-compilation models, see ASP.NET Web Site Pre-compilation. For more information about Web Application Projects, see Introduction to Web Application Projects.