Szworny Dziąch Szworny Dziąch - 3 months ago 8
ASP.NET (C#) Question

Loading part of web.config from other file

Rewriter section is defined as follows:

<section name="rewriter" requirePermission="false" type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />


Then the
<rewriter>
element looks like that:

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


Now, I have roughly 2000 urls that I need to redirect to some other domain. My
Web.config
file is big enough on its own but when I've put those 2000 urls into it, I got:
Cannot read configuration file because it exceeds the maximum file size
error message. If I'd put this data into some other config file, then how can I reference it from
Web.config
?

My app is running on ASP.NET 2.0 and uses this package: https://www.nuget.org/packages/Intelligencia.UrlRewriter for url rewriting.

Answer

As a variant you can change max size for web.config by tuning registry :)

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

Note If you configure IIS 7.0 and IIS 7.5 to run in 32-bit mode on Windows Server 2008 x64 or on Windows Server 2008 R2 x 64, the registry key is instead the following:

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