How to: Create a Business Module

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.

Business modules are units of development and deployment that typically include a combination of related Web pages, page flows, business logic, and services. You can use modules to encapsulate a set of concerns of your application and deploy them together. The following are examples of business modules:

  • A module that contains a specific application feature area, such as reports
  • A module that contains use cases around a specific back-end system, such as loan processing

This topic describes how to use the Add Business Module recipe to generate a business module.


The Add Business Module recipe assumes that you have an existing Web client solution. For information about how to create a Web client solution, see How to: Create a Web Client Solution.

The Add Business Module recipe applies to the Visual Studio solution folder (typically, this is the Modules solution folder).


The following procedure describes how to use the recipe to create a business module.

To use the Add Business Module recipe to create a business module

  1. In Solution Explorer, right-click a solution folder, point to Web Client Factory, and then click Add Business Module (C#) or Add Business Module (Visual Basic), as shown in Figure 1.


    Figure 5

    The Add Business Module recipe menu

  2. (Optional) In the Add New Project dialog box, illustrated in Figure 2, change the name of the project in the Name box and the location of the project in the Location box.


    Figure 6

    The Add Business Module project templates

  3. Click OK. The recipe starts the Add Business Module Wizard. The options available in the wizard depend on the Web Client Solution template that you selected when you created the initial solution. Figure 3 illustrates the first page of the wizard as it appears if you selected the Web Client Solution (C#, Web Site) template.


    Figure 7

    The Add Business Module recipe wizard for a Web Site Project solution

    Figure 4 illustrates the first page of the wizard as it appears if you selected a Web Application project solution template.


    Figure 8

    The Add Business Module recipe wizard for a Web Application project solution

  4. Under Web site in the left pane, click the Web site for the module folder (the recipe will create the folder in the selected Web site; this folder will contain the Web pages for the module).

  5. (Optional) If you want the module folder to have a different name than the module name, enter the new name in the text box for the folder name.

  6. (Optional) If you created the Web client solution with the Web Application project template, you will see the Create a sub-Web Application Project check box. If you select this check box, the recipe creates a Web Application project in the folder for the Web pages.

  7. (Optional) If you want to create a separate project that contains the public interface for the module, select the Create an interface library for this module check box. By using a separate project for the public interface of the module, you reduce the coupling between the business module and other modules in the application because modules reference the interface project instead of the module assembly.

  8. (Optional) If you want a test project for the module to be created with test classes for your module components, select the Create project for unit tests check box.

  9. Click Finish. The recipe generates the business module.


You will have the following elements in your solution:

  • A C# class library project. This is the module class library. It contains a default view interface with a presenter, an empty folder named Services, a module initialization class, and a module controller.
  • A folder in the Web site with a default view implementation and a Web.config file. The Composite Web Application Block uses the module information in the Web.config file to load the module when the application starts.
  • (Optional) A class library project that contains the public interface. This is a project that you can use to define the public interface that you want to share with other modules.
  • (Optional) A test project for the module. This project includes unit tests for the module initialization class and the presenter class of the default view. It also includes a mock module controller you can use to test your presenters. Figure 5 illustrates a solution with a test project.


Figure 9

Web client solution with the business module project Module1, the interface project Module1.Interface and the test project Module1.Tests

If you select the Create as sub-Web Application Project option, the solution will contain the project for the Web Application project. Figure 6 illustrates a solution with a Web Application project.


Figure 10

Web client solution with a Web Application project for business module Module1

Next Steps

After you run the Add Business Module recipe, you are ready to perform one of the following steps:

  • Add master pages, pages, and user controls to the module. You can add these items implementing the Model-View-Presenter pattern by using the Add Master Page (with presenter), Add Page (with presenter), and Add User Control (with presenter) recipes. For information about how to run these recipes, see How to: Add a Master Page with a Presenter, How to: Add a Page with a Presenter, and How to: Add a User Control with a Presenter.
  • Implement the module initializer. In the module initializer, you write code that will be executed when the application starts and loads the module. Typically, a module initializer performs the following tasks:
    • Registers module and global services. For more information related to registering and using services, see How to: Register and Use Services.
    • Exposes module features to the UI. By default, the Add Business Module recipe adds a module site map node to the site map. You can add more nodes if you want the user to be able to navigate directly to a particular page in the module. For more information about how to expose module features to the UI, see How to: Add Module Pages to the Site Map.
  • Implement module-specific business logic. Typically, business logic is implemented in the module controller and in services:
  • Implement navigation logic. Typically, navigation logic is implemented in the module controller. You can use the Page Flow Application Block to build complex page flows.