Rewrite maps in IIS Make web.config too big

I am moving a website that will / will work in IIS and I will use rewriting maps to 301 redirect the old ".asp" URLs to the new URL style. For many thousands of URLs there is no template, so I have to rely on rewriting maps.

My problem is that the default limit for web.config is 250 KB, and in my environment I do not have access to change this parameter (how can this be done at the registry level - if you had access).

I studied moving the rewriteMaps section to an external file, but external files also have a default limit of 250 kg, so this will not work either.

I'm looking for some other way to handle this ... I am sitting at 242kb today and have more than double the old for the new redirect mapping to add.

Thanks in advance.

+7
web-config iis-7
source share
3 answers

Since I'm in a shared environment, there was no other solution than to move it to one external configuration file, which again was limited to 250 KB.

So here is what I did:

I filled the map with capacity with the highest redirected redirects and, of course, with any groups of URLs that could be redirected using the template (to make them faster).

For the 100k remaining long tail of the redirect, I put them in the REDIRECTS table in db ... SO, after the request passes all the rewrite rules in the file (and, of course, does not fall into any), it by default requests a specific script. One of the first things the script does is check the REDIRECTS table, and if the record exists, I redirect in the code ... it is slower, but most of the material in the table is long, and as I said, the most visited redirects are still are in the file. So far, this has worked well, and I can add as many redirects as I want ... for example. if the title / url of the page is being edited, my admin area automatically adds a redirect, etc.

+1
source share

The Nativerd.dll file uses the value of this registry key to determine the maximum size in KB for Web.config files. The configuration system assumes a default value of 250 KB in Windows Server 2008 and 100 KB in the version for Windows Vista.

The reason for the 250KB limitation is to reduce attacks for downloading a large web.config file. You can change the limit by changing the upper value in your registry:

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

See: Description of registry keys used by IIS 7.0, IIS 7.5, and IIS 8.0

Another option is to split the web.config files into several smaller files.

0
source share

You can split your configuration into several different files, as Neil said.

You will have the main web.config file in which you will reference the auxiliary configuration files by adding the configSource attribute to the sections that you would like to split into other files.

For example, if you want to separate the "appsettings" section in another file, you change the appSettings section in the web.config file to:

 <appSettings configSource="appsettings.config" /> 

and in the appsettings.config file you add all your appsettings entries, for example, to the source web.config file;

  <appSettings> <add key="aspnet:RestrictXmlControls" value="true" /> <add key="FeedCacheTime" value="300" /> <add key="FeedPageUrl" value="/_layouts/15/feed.aspx?" /> <add key="FeedXsl1" value="/Style Library/Xsl Style Sheets/Rss.xsl" /> <add key="aspnet:AllowAnonymousImpersonation" value="true" /> </appSettings> 

Obviously, cards are being overwritten instead.

-one
source share

All Articles