【问题标题】:Loading part of web.config from other file从其他文件加载 web.config 的一部分
【发布时间】:2016-08-08 12:35:31
【问题描述】:

重写器部分定义如下: <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/$1" />
    </if>
    <!-- some other rules -->
</rewriter>

现在,我有大约 2000 个网址需要重定向到其他域。我的 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 重写。

【问题讨论】:

标签: asp.net url-rewriting web-config urlrewriter.net


【解决方案1】:

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

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

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

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

【讨论】:

  • 我宁愿使用单独的文件,但是如果我不能,那么我可能会使用你的创造性方法;)。
  • 您的评论为我指明了正确的方向,因为我发现了这个:stackoverflow.com/questions/11824596/…。但是,我不能接受你的评论作为答案,所以我只接受这个:)。
猜你喜欢
  • 2012-03-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-04
  • 2012-01-22
  • 1970-01-01
相关资源
最近更新 更多