This project is read-only.

How to: Create a Business Module

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
  • In Solution Explorer, right-click a solution folder, point to Web Client Factory, and then click Add Business Module (C#) orAdd Business Module (Visual Basic), as shown in Figure 1.
Figure 1
The Add Business Module recipe menu.
  • (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 2
The Add Business Module project templates.
  • 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 3
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 4
The Add Business Module recipe wizard for a Web Application project solution.
  • 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).
  • (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.
  • (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.
  • (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.
  • (Optional) If you want to see a summary of the recipe actions and suggested next steps after the recipe completes, select the Show documentation after recipe completes check box.
  • 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 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 5
Web client solution with the business module Module1 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 6
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.

Last edited Nov 20, 2007 at 2:19 PM by ejadib, version 3


No comments yet.