ArticleDirectory
How to create an ASP. NET application from multiple projects for team development
Article ID |
: |
307467 |
Last Review |
: |
July 15,200 4 |
Revision |
: |
1.0 |
This article was previusly published under q307467
In this task
• |
Summary |
|
• |
Requirements |
• |
Single Project Method |
• |
Multiple Project Method |
• |
Make multiple Visual Studio. NET projects maid in the same web application |
|
• |
Create the IIS application root Project |
• |
Create the child projects |
• |
Remove the IIS applications that correspond to the child projects |
• |
Set references to the child projects |
• |
Deploy multi-project applications to development computers |
|
|
SUMMARYThis article describes how to make multiple ASP. NET projects participant 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.
Back to the top
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 |
Back to the top
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 shoshould 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. |
Back to the top
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 shoshould 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 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 particle 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. |
Back to the top
Make multiple Visual Studio. NET projects maid in the same web application
To make the Visual Studio. net projects participant 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 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 inSameVisual 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. |
Back to the top
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 shoshould then appear as follows: http: // localhost/mainweb |
Back to the top
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, pointAdd, And then clickNew project. |
2. |
InAdd new projectDialog box, clickASP. NET web applicationUnderTemplates. |
3. |
InLocationText box, typeHttp: // localhost/mainweb/<subwebname>. This creates a child project named <subwebname> In a subdirectory of the root application directory. |
4. |
ClickOK. |
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. |
Back to the top
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. 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-clickReferences, And then clickAdd reference. |
2. |
InAdd referenceDialog box, clickProjectsTab. |
3. |
Select the child projects, and then clickOK. |
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.
Back to the top
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 available 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 program 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 clickCopy ProjectOnProjectMenu 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:
A. |
in the file system explorer, locate the root directory of the Web application. |
B. |
right-click the directory, and then click properties . |
C. |
In the properties dialog box, click the Web Sharing tab, and then click share this folder . |
D. |
In the alias box, type the name of the Web application, and then click OK . |
E. |
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. |
Back to the top
Applies
• |
Microsoft ASP. Network 1.1 |
• |
Microsoft Visual Studio. NET 2003 Professional Edition |
• |
Microsoft Visual Studio. NET 2003 enterprise effecect |
• |
Microsoft Visual Studio. NET 2003 enterprise developer |
• |
Microsoft Visual Studio. NET 2003 academic Edition |
• |
Microsoft ASP. Network 1.0 |
• |
Microsoft Visual Studio. NET 2002 Professional Edition |
• |
Microsoft Visual Studio. NET 2002 enterprise effecect |
• |
Microsoft Visual Studio. NET 2002 enterprise developer |
• |
Microsoft Visual Studio. NET 2002 academic Edition |