How To Create an ASP.NET Application from Multiple Projects for Team Development

Article translations Article translations
Article ID: 307467 - View products that this article applies to.
This article was previously published under Q307467
Expand all | Collapse all

On This Page

SUMMARY

This article describes how to make multiple ASP.NET projects participate in the same Web application.

You may find it useful to separate a large Web application project into multiple projects for team development of ASP.NET Web applications in Microsoft Visual Studio .NET. Microsoft recommends that you use source control software, such as Microsoft Visual SourceSafe, in all scenarios.

Developing a large Web site frequently involves several developers. These developers must be able to work on specific sections of a Web application without interfering with one another and yet still be able to use each other's work as the project progresses. To do this, you can use a single project in a Visual Studio .NET solution. You can also separate a Web application into multiple projects by dividing the development project into units to make development easier.

You can develop Web applications in single project or multi-project Visual Studio .NET solutions. The advantages and disadvantages of each method are outlined in the sections to follow.

Requirements

The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:
  • Microsoft Windows 2000 Professional, Microsoft Windows 2000 Server, Microsoft Windows 2000 Advanced Server, or Microsoft Windows XP Professional
  • Microsoft Internet Information Services (IIS)
  • Microsoft .NET Framework
  • Microsoft Visual Studio .NET
This article assumes that you are familiar with the following topic:
  • Creating Visual Studio .NET Web applications

Single Project Method

Microsoft recommends the single project method for small-sized to medium-sized Web applications. Visual Studio .NET directly supports this method. The whole Web application is built as a single ASP.NET Web application project. Each team member downloads a copy of the entire project to a development computer, where he or she develops part of the application. You should use source control software to coordinate the work of the team members on the files that make up the project.

The advantages of the single project method are as follows:
  • This method is easy to implement. You create a single Web application project in Visual Studio .NET, and then you add application items to it.
  • For smaller Web applications, a single Visual Studio .NET project is easy to manage.
  • Visual Studio .NET directly supports this method. You do not have to take special steps to make this method work.
  • Because the whole project is built into a single assembly, you do not need references between multiple assemblies.
The disadvantages of the single project method are as follows:
  • Large Web applications are difficult to manage as a single unit.
  • Every time you want to build your work, even for small code changes, you must build the whole project. For large projects, this can be very time consuming and can make development less efficient.

Multiple Project Method

If you separate the Web application into multiple Visual Studio .NET projects, you may find it easier to manage the development of large Web applications. You can separate a large development project into smaller projects, which you can manage and build separately. Your team can work on separate parts of a Web application by working on separate projects. You should still use source control software to coordinate work on project files.

Visual Studio .NET does not directly support this method because Visual Studio .NET Web projects are always created in their own IIS application root directories with their own assemblies. IIS Web applications cannot span multiple IIS application root directories.

Additionally, you cannot use resources in one root directory from other root directories in Visual Studio .NET. It is difficult to create a single application from multiple projects if these applications cannot share resources.

To resolve these problems, you can use the procedure in the Make Multiple Visual Studio .NET Projects Participate in the Same Web Application section so that multiple Visual Studio projects share the same IIS application root directory.

The advantages of the multiple project method are as follows:
  • It is easier to manage smaller units of a large Web application.
  • You can build each project separately from the other projects, which shortens the build times during development.
  • You can divide a large Web application into logical units and have these units share common resources, such as controls.
The disadvantages of the multiple project method are as follows:
  • Visual Studio .NET does not directly support this method. You must perform additional steps so that separate Visual Studio .NET projects participate in the same Web application.
  • Assemblies that access each other's resources must set references to each other. Visual Studio .NET does not allow circular references.
  • This method is not ideal for small Web applications. For small Web applications, it is more complex to manage multiple projects than to manage a single project.

Make Multiple Visual Studio .NET Projects Participate in the Same Web Application

To make the Visual Studio .NET projects participate in the same Web application, the projects must share the same IIS application root directory. Visual Studio .NET creates Web projects in their own application root directories. Therefore, you must configure this separately.

To make the Visual Studio .NET projects participate in the same Web application, you must complete four main steps:
  1. Create the main project in a directory that is the root directory for the whole application.
  2. Create the child projects in subdirectories of the root directory in the same Visual Studio .NET solution.
  3. Remove the Web applications that Visual Studio .NET creates for the child projects through IIS.

    NOTE: Because Visual Studio .NET does not allow you to create or to work with multiple Web applications in the same physical directory, you must create the various projects that make up your application in separate directories.
  4. To deploy the projects to individual development computers, copy the application directory structure to those computers, and then create an IIS application root directory for the main project directory.

Create the IIS Application Root Project

To create the IIS application root project for the Web application, follow these steps:
  1. Start Visual Studio .NET.
  2. On the File menu, point to New, and then click Project.
  3. In the New Project dialog box, click the language that you want to use under Project Types, and then click ASP.NET Web Application under Templates.
  4. In the Location text box, replace the WebApplication# default name with MainWeb. If you are using the local server, you can leave the server name as http://localhost. The Location box should then appear as follows:
    http://localhost/MainWeb

Create the Child Projects

To create the child projects, follow these steps:
  1. For each child project, right-click the solution in the Solution Explorer window, point to Add, and then click New Project.
  2. In the Add New Project dialog box, click ASP.NET Web Application under Templates.
  3. In the Location text box, type http://localhost/MainWeb/<subwebname>. This creates a child project named <subwebname> in a subdirectory of the root application directory.
  4. Click OK.
  5. Delete any files that are not needed for a non-application root directory from the project. Specifically, delete the Global.asax and the Web.config files. This child project will rely on the Global.asax and the Web.config files from the main project.
  6. If the child project will only contain shared resources, such as user controls, delete the WebForm1.aspx file.
  7. Build the solution.

Remove the IIS Applications That Correspond to the Child Projects

To remove the IIS applications that correspond to the child projects, follow these steps:
  1. Click Start, point to Programs (or All Programs in Windows XP), point to Administrative Tools, and then click Internet Services Manager.
  2. Locate your main Web application and the child Web projects that you want to remove.
  3. For each child project, right-click the Web application node, and then click Properties.
  4. On the Directory tab, click Remove, and then click OK.

    IMPORTANT: Do not click Delete. This can permanently delete the corresponding file directory and your project files.
After you configure the child projects to share a common IIS application root directory, you can share resources between projects in the solution. For example, you can drag a user control from a shared resources project into an .aspx file in another project. Note that you can only do this after you configure the projects to share a common IIS application root. Visual Studio .NET does not allow you to share resources if the projects are still in separate IIS application root directories.

Set References to the Child Projects

To add references to the main Web application for all of the child projects, follow these steps.
  1. In Solution Explorer of the main Web application, right-click References, and then click Add Reference.
  2. In the Add Reference dialog box, click the Projects tab.
  3. Select the child projects, and then click OK.
After you set references to the child projects, when you build the solution, the child project assemblies are copied to the Bin directory of the main application. You can then debug and use the components that are defined in the child projects.

Deploy Multi-Project Applications to Development Computers

To deploy the multi-project Web application to a development computer, you must copy the main (root) project that represents the root of the Web application, as well as any child applications that you want to work on. You must make the main project directory the root of an IIS Web application.

There are many options for deployment, and it is beyond the scope of this article to describe each option. For example, you can deploy built versions of some of the source files in large Web applications to avoid bringing in many source files. Any references to local projects must be project references. If you want to drag ASP.NET user controls from another project onto a Web Form, the project that contains the user control must exist on your computer and in your solution.

For smaller ASP.NET Web applications, you can combine all of the projects. A good way to do this is to click Copy Project on the Project menu in Visual Studio .NET. You can also copy the project files to a computer.

To deploy the multi-project Web application to a development computer, follow these steps:
  1. Copy the whole directory structure that you created in the previous steps to a development computer.
  2. Make the directory that contains the root project an IIS application root. The easiest way to do this is to use the File System Explorer (if you are working with the NTFS file system) as follows:
    1. In the File System Explorer, locate the root directory of the Web application.
    2. Right-click the directory, and then click Properties.
    3. In the Properties dialog box, click the Web Sharing tab, and then click Share this folder.
    4. In the Alias box, type the name of the Web application, and then click OK.
    5. Click OK to close the Properties dialog box.
  3. Make sure that all of the user identities who will be using the Web application (such as the IUSR account) have access to the directories.
  4. Build the solution.

Properties

Article ID: 307467 - Last Review: July 15, 2004 - Revision: 3.5
APPLIES TO
  • Microsoft ASP.NET 1.1
  • Microsoft Visual Studio .NET 2003 Professional Edition
  • Microsoft Visual Studio .NET 2003 Enterprise Architect
  • Microsoft Visual Studio .NET 2003 Enterprise Developer
  • Microsoft Visual Studio .NET 2003 Academic Edition
  • Microsoft ASP.NET 1.0
  • Microsoft Visual Studio .NET 2002 Professional Edition
  • Microsoft Visual Studio .NET 2002 Enterprise Architect
  • Microsoft Visual Studio .NET 2002 Enterprise Developer
  • Microsoft Visual Studio .NET 2002 Academic Edition
Keywords: 
kbdeployment kbhowtomaster kbideproject kbwebforms KB307467

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com