Part 1 of 3: Creating sub-projects in IIS with Web Application Projects

Part 1 of 3: Creating sub-projects in IIS with Web Application Projects

Rate This
  • Comments 60

First a quick intro, since this my first post on the team blog.  My name is Omar Khan.  I'm the group program manager for the web development tools team.  I manage the program management team that helps design the web tools inside of Visual Studio.

This post is one of a three part series that describes how to factor development of a single large ASP.NET application into multiple projects inside of Visual Studio 2005 using the Web Application Projects add-in.

Part 1 of 3: In this post, I’ll describe the basics on how to setup a sub-project structure using IIS. 

Part 2 of 3: The next post will describe intricacies with master pages, user controls, and project references when using a sub-project structure.

Part 3 of 3: The final part to the series will describe how to use the same technique but with the built-in development server in Visual Studio 2005.

Why use sub-projects?

With very large web applications, such as those that contain thousands of files, using a sub-project structure in Visual Studio provides several benefits. 

At development time, it provides a clean isolation between different parts of the application.  This enables different developers to own their own projects within a single web application, and allows them to make changes without affecting code that is in a different project.

As well, using sub-projects provides a clean way to compartmentalize functionality so different parts of the application can be developed in isolation from others.  The compartmentalization also enables the ability to deploy the various sub-projects to production independently from each other thus providing more flexibility around incremental updates to one part of the application without affecting other parts. 

Setting up the root project using IIS

The first thing I want to show is a step-by-step on how to setup a sub-project project structure based on developing on IIS. 

Setting up a sub-project structure in Visual Studio 2005 is fairly straightforward.  If one has done it in Visual Studio 2003, the process described below should be very familiar. 

Here is a step-by-step walkthrough of how to setup sub-projects using Visual Studio 2005 and the Web Application Projects add-in.

1)    Download and install “Web Application Projects” add-in.  The add-in can be installed from the following location:

2)    Create the root project.  The first thing we want to do is create a new Web Application project that will represent the root of the application in IIS.  To do this select File > New Project.  Choose the ASP.NET Web Application item, and type in a name and location for the root project.  In this example we’ll call the root project MyLargeWebApp.  Make sure the “Create directory for solution” checkbox is unchecked.  One can create the “Root” project in a folder in the “inetpub/wwwroot” directory for IIS, or in any other location where you wish to create the virtual root for your app.  In this example, we’ll use a location underneath “inetpub/wwwroot”. 



3)    The next step is to map the MyLargeWebApp project in IIS using the “Web” tab in project properties.  To do this, right-click on the root node of the project and select “Properties”.  Click the “Web” tab on the page that is launched, and select the “Use IIS Web Server” option.


4)    Next you need to create a virtual directory mapping in IIS to point to the location where your root project exists.  To do this click the “Create Virtual Directory” button on the same Properties page.


5)    You can now test your root project, by adding some content to default.aspx and selecting F5.  This should run launch IE and the default.aspx page will get served from IIS.


Creating sub-projects under a root project

Once the root project is up and running fine, the next step is to create a sub-project and set it up so it builds and runs as part of the same ASP.NET application represented by the root project.  The following steps describe how to do this:

1)    The first thing you need to do is add a new Web Application project to the same solution.  Make sure the MyLargeWebApp solution/project is already open in the solution explorer.  To add a new project to the solution, select “File > Add > New Project”.  Select “ASP.NET Web Application” as the template.  Then type in a name for the sub-project (“SubProject1” in this example), and set it to the location of the folder where the root project is (c:\inetpub\wwwroot\MyLargeWebApp in this example).




2)    You should now have two projects in your solution which represent a single ASP.NET application.  To verify this, go to the IIS management console by selecting Start > Run > inetmgr in Windows.  In the management console, you should see a “SubProject1” folder under single IIS web application called “MyLargeWebApp”.



3)    To get the sub project building and running a few more steps are required in Visual Studio.  The first thing you should do is delete the web.config file in the sub-project.


4)    Next you need to adjust a few of the properties for the sub-project.  Right click on the sub-project’s node in solution explorer and select “Properties”.  Under the “Compile” page change the “Build output path” to “..\bin\”.




5)    Finally in the sub-project’s properties, under the “Web” page, select the “Use IIS Web Server” option and change the “Project URL” setting to “http://localhost/MyLargeWebApp/SubProject1”.  Also check the "Overwrite application root URL" and provide the URL to the root project, which in this case is "http://localhost/MyLargeWebApp/".  Do not click the “Create Virtual Directory” button in the sub-project’s setting as you don’t want to create another application root in IIS at the sub-projects folder.


6)    Once you’ve updated these properties for the sub-project, the sub-project should be ready to go.  Add some content to the default.aspx page in the sub-project and press F5.  This should build the sub-project, deploy its DLL to the \bin of the root project, and then run the page from the sub-project.  If you select the root-project and “Show All Files” in the solution explorer, you will see in its \bin folder that there are two deployed assemblies, one for the root project (MyLargeWebApp.dll) and one for the sub-project (SubProject1.dll).




This wraps up my first post on sub-projects.  Hopefully it provides a quick introduction on how to setup a sub-project structure using the Web Application Project add-in for Visual Studio 2005. 

As mentioned in the beginning of the post, sub-projects are a good way to partition a single large ASP.NET application into several Visual Studio projects so you get the benefits of isolated development and deployment.

Looking forward to hear from you about this post, and I'll update with Part 2 hopefully next week.


Leave a Comment
  • Please add 6 and 2 and type the answer here:
  • Post
  • I just installed the VS 05 SP1. I also installed the WAP add in. I think I got things set up right. Both .dlls are in the MyLargeWebApp\bin. When I run the root page it works fine. When I run the sub project I get the following error on Line 1:

    Server Error in '/' Application.


    Parser Error

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: Could not load type 'SubProject1._Default'.

    Source Error:

    Line 1:  <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="SubProject1._Default" %>

    Line 2:  

    Line 3:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

    Does anyone have any suggestions?



  • Can you please offer some advice on deploying the sub project? The publish feature compiles the entire sub project into it's own bin folder. I dabbled with Web Deployment Projects but don't yet understand them completely or if they are capable of accomplishing what I need. Maybe another article?



  • Hi all , very nice site! Thank You !

  • Earlier today, I posted to the WCSF CodePlex Community Site a new code-only guidance package, Web Application

  • I have a Sub-Project set up to use ASP.NET AJAX. My Master file and Web.config file are in the root project. My file lookup.aspx that implements the master file is in the Sub-Project. All references to the AJAX library are included in both root and sub projects. My problem is that when I start trying to include <asp:updatepanel in the lookup.aspx the designer complains that it doesnt know what an update panel is and subsequently nothing is added to the designer file.

  • Hi Jester - can you verify that an update panel works properly in the root project?  If that works send me an email (omark-at-microsoft-dot-com) and i'll see if I can help understand what is happening.

  • I presented this at my company and was told (after working on this for a week!) that the all of the sub-apps would be running in the same process, so if an unhandled error occurred in one sub-app it could cause the application pool to become corrupt and force a recycling that would affect every sub-app. This could cause a loss of all session data in every app.

    Since i am a noob I have no idea if this true. Help!


    PS-I noticed that this structure allows you to share session variables between applications

  • I encounter that the subproject throws an error on AJAX: "Element name is not a known element. This can occur if there is a compilation error in the Web site." I use the method in which after a build the ascx are copied into the root bin :


  • I have same problem as with AJAX, but then with the controltoolkit.

    Error 2 The name 'MyAccordion' does not exist in the current context Error 3 Element 'Accordion' is not a known element. This can occur if there is a compilation error in the Web site.

    <%@ Control Language="C#" Inherits="V4A.Modules.PNGT.ViewPNGT" CodeFile="ViewPNGT.ascx.cs" AutoEventWireup="true" %>

    <%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" Namespace="System.Web.UI" TagPrefix="asp" %>

    <%@ Register Assembly="AjaxControlToolkit" Namespace="System.Web.UI.WebControls.WebControl" TagPrefix="ajaxToolkit" %>

    <div class="demoarea">

    <ajaxToolkit:Accordion id="MyAccordion" runat="server" TransitionDuration="150" FadeTransitions="true" AutoSize="None" HeaderCssClass="pnavH">




    The designer did not have the items in the toolbox. A pitty, but solved.

  • Introduction The recent release of WCSF 1.1 includes support for the Web Application Projects . Not only

  • 本周ASP.NET英文技术文章推荐[11/26-12/02]


  • Its really grt articla, helps me alot in my new project development

  • I have two project in single solution named as Main_Project and Sub_Project.

    In Main_Project i have Login.aspx page where i am writing value in Session after that I am redirecting to page which is in Sub_Project and in page load i want to read the session value which i have stored in Login page of project first.

    For this purpose I have used SQLServer session mode where the session value has been saved in database but I am not able to read the session value in next page.

    I want to use server side and secure way to transfer session.

    So please reply with solution.

  • The paragraph

    Finally in the sub-project’s properties, under the “Web” page, select the “Use IIS Web Server” option and change the “Project URL” setting to “http://localhost/MyLargeWebApp/SubProject1”.  Also check the "Overwrite application root URL" and provide the URL to the root project, which in this case is "http://localhost/MyLargeWebApp/".  Do not click the “Create Virtual Directory” button in the sub-project’s setting as you don’t want to create another application root in IIS at the sub-projects folder.

    and the corresponding picture don't match. Can you tell me what is yhe correct one?

Page 4 of 4 (60 items) 1234