你的位置:首页 > ASP.net教程

[ASP.net教程][转】IIS:Do not nest virtual directories


原文:https://msdn.microsoft.com/en-us/library/ms178685.aspx#Anchor_6

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.(直接通过vdir2访问资源时,vdir1下的web.config不会被继承。) Creating virtual directories in this manner can cause unexpected results, or even an application failure. It is recommended that you do not nest virtual directories, or if you do, use only one Web.config file.