gpt4 book ai didi

asp.net - 将 从单独的配置文件中的 web.config 中移出

转载 作者:行者123 更新时间:2023-12-02 19:04:23 24 4
gpt4 key购买 nike

我们的 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>

注意我只尝试过使用其他配置元素。

关于asp.net - 将 <httpredirect> 从单独的配置文件中的 web.config 中移出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15360462/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com