配置子目录Web.config使其消除继承,iis7.0设置路由

iis7.0设置路由 ,url转向,伪静态

<system.webServer>  
    <modules runAllManagedModulesForAllRequests="true" />  
    </system.webServer>

配置子目录Web.config使其消除继承  

不用修改根目录的Web.config文件,而是修改子目录的Web.config。假设根目录的Web.config设置了一个名为 BlogEngine的连接字符串,要在子目录使用另一个名字为BlogEngine的连接字符串,就需要先清除已有的连接字符串(根目录继承下来的 connectionString设置),清除所有的配置,可以用clear语法,清除指定名称的配置,可以用remove语法,如下

<--根目录的Web.config-->
<connectionStrings>  <add name="BlogEngine" connectionString="Data Source=localhost\SQLEXPRESS; Initial Catalog=BlogEngine1; User ID=xxx; Password=xxx" providerName="System.Data.SqlClient"/> </connectionStrings>
<--子目录的Web.config(clear方法)-->
<connectionStrings> <clear/> <add name="BlogEngine" connectionString="Data Source=localhost\SQLEXPRESS; Initial Catalog=BlogEngine2; User ID=xxx; Password=xxx" providerName="System.Data.SqlClient"/> </connectionStrings>
<--子目录的Web.config(remove方法)-->
<connectionStrings> <remove name="BlogEngine"/> <add name="BlogEngine" connectionString="Data Source=localhost\SQLEXPRESS; Initial Catalog=BlogEngine2; User ID=xxx; Password=xxx" providerName="System.Data.SqlClient"/> </connectionStrings> 

这里只是用connectionString为例,使用时完全可以应用在所有可以配置的节点上,任何配置节点都可以用clear和remove节点 将继承来的配置先清除掉,然后再add新的配置。此方法灵活性更强,同时可以保留根目录Web.config中的部分共同配置(而无需全部重新设定)。

 

转载于:https://www.cnblogs.com/w158357686/p/4579954.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值