2015年5月6日 星期三

子應用程式的web.config不受上層web.config的影響

在Google上看了很多前輩的相關文章,都提到要在上層web.comfig加入
<location path="." inheritInChildApplications="false">
    <system.web>
    </system.web>
</location>

但一直無效,最後在一國外網站找到解決,原來<location path="." inheritInChildApplications="false"></location>不是只框住<system.web></system.web>就好,而是要把會影響到子應用程式的區域都框起來。
例如:
<!-- 要遮掉的區域 -->
<location path="." inheritInChildApplications="false">
   <connectionStrings>
   </connectionStrings>
</location>

<!-- 要留的區域 -->
<appSettings>
</appSettings>

<!-- 要遮掉的區域 -->
<location path="." inheritInChildApplications="false">
   <system.web>
        <webParts>
        </webParts>
        <membership>
        </membership>

        <compilation>
        </compilation>
      </system.web>
 </location>


解決方法來源:http://stackoverflow.com/questions/782252/avoid-web-config-inheritance-in-child-web-application-using-inheritinchildapplic


沒有留言:

張貼留言