External configuration file for part of the configuration section

I am trying to use an external configuration file to define several items locationin the root section of <configuration>my web.config file. Is it possible?

I understand how to do this for one section (for example, connectionStrings), but can it be done for several elements in a configuration item? <configuration>; the attribute itself does not allow configSource. Is it possible to create a dummy element and define it in configSections, if so, what type do I give it?

Background information: I want to do this to determine persistent redirects, there can be hundreds of them, so I don’t want to define this in web.config itself. i.e.

<configuration>
  <!-- rest of web.config here -->
  <!-- i need mutiple location elements so want these in an external file-->
  <location path="oldpage">
    <system.webServer>
      <httpRedirect enabled="true" destination="/uk/business" httpResponseStatus="Permanent" />
    </system.webServer>
  </location>
</configuration>
+3
source share
2 answers

, . URL- URL- CodeMonkey, http://www.iis.net/download/URLRewrite.

, web.config, ( system.webServer)

<rewrite>
  <rewriteMaps configSource="RewriteMaps.config" />                
  <rules>
      <rule name="Rewrite rule1 for StaticRewrites">
          <match url=".*" />
          <conditions>
              <add input="{StaticRewrites:{REQUEST_URI}}" pattern="(.+)" />
          </conditions>
          <action type="Redirect" url="{C:1}" redirectType="Permanent" appendQueryString="false" />
      </rule>
  </rules>        
</rewrite>

NB: VS XML Schema, http://ruslany.net/2010/04/visual-studio-xml-intellisense-for-url-rewrite-2-0/ (, re. js vs2010)

+1

, , :

<rewrite>
  <rules configSource="rewrites.config" />
</rewrite>

.

configSource .

+1

All Articles