I’m trying to use an external configuration file to define multiple location elements within the the root <configuration> section of my web.config file. Is this possible?
I understand how to do this for a single section (e.g. connectionStrings) but can this be done for multiple elements within the configuration element? <configuration>; itself doesn’t allow the configSource attribute. Is it possible to create a dummy element and define it in configSections, if so what type do I give it?
Background information: I am wanting to do this so that I can define permanent redirects, there may be hundreds of them so ideally 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>
Thought I’d add some more detail on this. As alluded to by CodeMonkey URL Rewrite module is the way to go, for more details on rewrite module http://www.iis.net/download/URLRewrite.
These are the changes I made to web.config defining rule and referncing external file (in
system.webServer)NB: also need to update VS XML Schema to stop it moaning quite so much
http://ruslany.net/2010/04/visual-studio-xml-intellisense-for-url-rewrite-2-0/
(make sure you see the comment on this blog re. updating the js for vs2010)