When setting up multiple ASP.NET sites under a single domain with subdirectory paths (like example.com/community), many administrators confuse virtual directories with applications. The key distinction:
- Virtual directories simply map physical paths to URL paths
- Applications run in isolated execution contexts with their own config
Here's how to properly configure this in IIS Manager:
1. Create parent site (example.com):
- Physical path: C:\sites\main
- Binding: example.com:80
2. For /community sub-site:
- Right-click parent site → Add Application
- Alias: community
- Physical path: C:\sites\community
- Application pool: (create new or select existing)
3. For /labs sub-site:
- Repeat above with appropriate paths
- Each gets independent web.config
To prevent conflicts between sites:
- Separate application pools for isolation (memory leaks/crashes won't affect parent)
- In each application's web.config:
<location path="." inheritInChildApplications="false">
<system.web>
<compilation debug="true" targetFramework="4.7.2" />
</system.web>
</location>
Sample parent site structure:
C:\sites\
├── main\ (parent site)
│ ├── default.aspx
│ └── web.config
├── community\ (sub-application)
│ ├── default.aspx
│ └── web.config
└── labs\ (sub-application)
├── default.aspx
└── web.config
Each web.config can have completely different settings while sharing the same domain and port.
- HTTP Error 500.19: Verify physical paths and NTFS permissions
- Configuration inheritance: Use
<clear/>
in child web.config if needed - Authentication conflicts: Set
inheritInChildApplications="false"
for auth sections
When deploying multiple ASP.NET applications under a single domain in IIS7, the standard approach of creating separate sites with different ports or host headers isn't always ideal. What we need is a way to:
- Maintain a primary site at the root domain (www.example.com)
- Host completely independent applications in subdirectories (/community, /labs)
- Use a single port (80) for all sites
- Keep each application isolated with its own configuration
The key is using Virtual Applications rather than Virtual Directories. Here's how they differ:
<!-- Example applicationHost.config snippet -->
<application path="/community" applicationPool="CommunityAppPool">
<virtualDirectory path="/" physicalPath="C:\sites\community" />
</application>
<application path="/labs" applicationPool="LabsAppPool">
<virtualDirectory path="/" physicalPath="C:\sites\labs" />
</application>
1. Create your main site first (right-click Sites > Add Web Site)
2. For each subdirectory application:
- Right-click the main site > Add Application
- Alias: "community" (this becomes your URL path)
- Application pool: Create or select dedicated pool
- Physical path: Point to the application's root folder
Application Pool Isolation: Always use separate application pools for each virtual application to prevent configuration conflicts.
Authentication Inheritance: By default, sub-applications inherit authentication settings. To override:
<location path="community" allowOverride="false">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</location>
To make sub-applications appear as root paths in their own context:
<rewrite>
<rules>
<rule name="Community Rewrite" stopProcessing="true">
<match url="^community/(.*)" />
<action type="Rewrite" url="{R:1}" />
</rule>
</rules>
</rewrite>
HTTP 500.19 Errors: Typically occur when the sub-application's web.config improperly inherits or conflicts with parent settings. Solution:
<clear /> <!-- In authentication sections -->
<remove name="ModuleName" /> <!-- For module conflicts -->
Session Conflicts: Ensure each application uses unique machineKey values in web.config when sharing the same domain.