IIS中不让下级虚拟目录继承本级的web.config配置

日前遇到一个问题:在默认网站下建立虚拟网站时,虚拟站报web.config 的配置错误。检查发现是默认网站的配置,而非虚拟站的。虚拟站下没有相关的引用,所以报错。

解决方法有二:

1. 把相关的引用也加入到虚拟站中。

2. 配置默认网站的web.config为不向下继承。

把除了configSecton之外的东西都放到

<location path="." inheritInChildApplications="false">       
</location>
里面去
如 :
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<configSections>
...
</configSections>
<location path="." inheritInChildApplications="false">

Put your configuration code here.........

</location>
</configuration>

原文地址:https://www.cnblogs.com/jishu/p/1940065.html