从其他文件加载 web.config 的一部分

Loading part of web.config from other file

重写段定义如下: <section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />

那么 <rewriter> 元素看起来像这样:

<rewriter>
    <if header="Host" match="^example.com">
      <redirect url="~/(.*)" to="http://www.example.com/" />
    </if>
    <!-- some other rules -->
</rewriter>

现在,我有大约 2000 个 url 需要重定向到其他域。我的 Web.config 文件本身就足够大了,但是当我将 2000 url 放入其中时,我收到:Cannot read configuration file because it exceeds the maximum file size 错误消息。如果我将这些数据放入其他配置文件中,那么如何从 Web.config?

中引用它

我的应用程序 运行 ASP.NET 2.0 并使用此包:https://www.nuget.org/packages/Intelligencia.UrlRewriter 进行 url 重写。

作为变体,您可以通过调整注册表来更改 web.config 的最大大小:)

HKLM\SOFTWARE\Microsoft\InetStp\Configuration\MaxWebConfigFileSizeInKB  (REG_DWORD)

注意如果在 Windows Server 2008 x64 或 Windows Server 2008 R2 x 64 上以 32 位模式将 IIS 7.0 和 IIS 7.5 配置为 运行,注册表项而是以下内容:

HKLM\SOFTWARE\Wow6432Node\Microsoft\InetStp\Configuration\MaxWebConfigFileSizeInKB (REG_DWORD)