加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 在单独的配置文件中移出web.config

发布时间:2020-12-16 06:26:27 所属栏目:asp.Net 来源:网络整理
导读:我们的web.config中有很多(超过100个)重定向 configuration system.webServer httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found" add wildcard="/a" destination="/a/dfdf/default.htm" / add wildcard="/sad" destination="
我们的web.config中有很多(超过100个)重定向

<configuration>
   <system.webServer>
      <httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
         <add wildcard="/a" destination="/a/dfdf/default.htm" />
         <add wildcard="/sad" destination="/aasd/dfdf/defsadault.htm" />
         <add wildcard="/asdsaa" destination="/aasdas/dfasddf/default.htm" />
         <add wildcard="/aasdsa" destination="/asdsaa/dfdf/defsdault.htm" />
         <add wildcard="/aasd" destination="/adsa/dfdf/default.htm" />
..... more than 100
      </httpRedirect>
   </system.webServer>
</configuration>

我们是否可以在单独的web.config或任何其他最佳解决方案中管理此部分?

解决方法

您可以将一些配置元素移动到自己的配置文件中,以减少web.config中的混乱.

<configuration>
   <system.webServer>
      <httpRedirect configSource="httpRedirects.config" />
   </system.webServer>
</configuration>

这是通过添加如上所示的configSource属性来实现的.

在你的单独httpRedirects.config中

<httpRedirect enabled="true" exactDestination="true" httpResponseStatus="Found">
     <add wildcard="/a" destination="/a/dfdf/default.htm" />
     <add wildcard="/sad" destination="/aasd/dfdf/defsadault.htm" />
     <add wildcard="/asdsaa" destination="/aasdas/dfasddf/default.htm" />
     <add wildcard="/aasdsa" destination="/asdsaa/dfdf/defsdault.htm" />
     <add wildcard="/aasd" destination="/adsa/dfdf/default.htm" />
</httpRedirect>

注意我只尝试过其他配置元素.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读