Deploying Application Blocks

How to: Deploy Modules

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.

Steps

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 XCopy deploy a module to a Web site using 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 XCopy deploy a module to a Web site using ASP.NET default compilation
  • Copy the module's assembly to the Bin folder of the Web site.
Note:
Modifying the content of the Bin folder when the Web application is running will cause ASP.NET to restart the application.
  • 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.
  • 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:
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 XCopy deploy a module created as a sub-Web application project.

To XCopy deploy a module created as a sub-Web Application Project
  • 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)
  • Create a folder for the module in the Web site and copy the module's ASP.NET Web pages to this folder.
  • 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 XCopy deploy a module to a Web site using ASP.NET precompilation (with ASP.NET precompilation, you precompile the Web site and deploy the compiled files to the production server with no code behind files).

To XCopy deploy a module to a Web site using ASP.NET precompilation
  • Precompile the Web site and store the output in a location different than the production Web site location. For more information about how to precompile a Web site using the ASP.NET Compilation Tool (aspnet_compiler.exe), see How to: Precompile ASP.NET Web Sites for Deployment. For more information about how to precompile a Web site using the Publish Web Site utility that integrates with Visual Web Developer, see Publishing Web Sites.
  • Copy the module's assembly to the Bin folder of the production Web site.
Note:
Modifying the content of the Bin folder when the Web application is running will cause ASP.NET to restart the application.
  • Create a folder for the module in the production Web site and copy the precompiled module's ASP.NET Web pages to this folder.
  • Copy the precompiled assemblies of the module’s Web pages to the Bin folder of the production Web site.
Note:
If you are precompiling for deployment only (with non-updateable UI), you must also copy the .compiled files to the Bin folder of the production Web site.
  • 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 following procedure.
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
  • Open the Web site Web.config file.
  • 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> 
  • 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 precompilation) for the Web pages in the Bin folder of the Web site.
Figure 1 illustrates a module deployment example.
ModuleDeploymentExample.PNG
Figure 1
Module deployment example

Related Information

For more information about ASP.NET precompilation models, see ASP.NET Web Site Precompilation. For more information about Web Application Projects, see Introduction to Web Application Projects and Visual Studio 2005 Web Application Projects.

Deploying Application Blocks

Last edited Jan 17, 2008 at 3:44 PM by siacomuzzi, version 3

Comments

No comments yet.