Custom Search Tailored for Microsoft .NET  
Aspexception.com Skip Navigation Links
Error RepositoryExpand Error Repository
.NET ResourcesExpand .NET Resources
About
Skip Navigation LinksHome > .NET Resources > How to tips... > Avoid Configuration Conflict...
How to Avoid Configuration Conflicts Between Settings on Virtual and Physical Directories in ASP.NET
ASP.NET configuration files are called Web.config files, and they can appear in multiple directories in ASP.NET applications.

All .NET Framework applications inherit basic configuration settings and defaults from a file named systemroot\Microsoft .NET\Framework\versionNumber\CONFIG\Machine.config. The Machine.config file is used for server-wide configuration settings.

The ASP.NET applications use configuration files named Web.config to override inherited settings. Configuration settings for virtual directories are independent of physical directory structure, and virtual directories must be organized carefully to avoid configuration problems. For example, you could have an ASP.NET file named MyResource.aspx with the following physical directory structure.

C:
    \Subdir1
        \Subdir2
            \MyResource.aspx
In addition, you might have a configuration file that is located in Subdir1, a virtual directory named Vdir1 that is mapped to c:\Subdir1, and a virtual directory named Vdir2 that is mapped to c:\Subdir1\Subdir2. If a client accesses the resource with the physical location of c:\Subdir1\Subdir2\MyResource.aspx using the URL http://localhost/vdir1/subdir2/MyResource.aspx, the resource inherits configuration settings from Vdir1. However, if the client accesses the same resource using the URL http://localhost/vdir2/MyResource.aspx, it does not inherit settings from Vdir1. Creating virtual directories in this manner can cause unexpected results, or even an application failure.

To avoid such conflict, tt is recommended that you do not nest virtual directories, or if you do, use only one Web.config file.

For details, see ASP.NET Configuration File Hierarchy and Inheritance from MSDN.
Site Map  Copyright © Aspexception.com 2008. All rights Reserved. Terms of Use