1

We are using IIS7 URL rewrite module with asp.net C#, all of the URLs are configured and written directly into web.config:

<system.webServer>
    <!-- ... -->
    <rewrite>
        <rules>
            <clear />
            <rule name="Category URL" stopProcessing="true">
                <match url="somepage.aspx" ignoreCase="false"/>
                <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                    <add input="{QUERY_STRING}" pattern="REDIRECTION=true"
                         ignoreCase="false"/>
                    <add input="{QUERY_STRING}" pattern="categoryid=([^&amp;]*)"/>
                </conditions>
                <action type="Redirect" url="http://{HTTP_HOST}/browsing/categorylanding.aspx?navcategoryid={C:1}"/>
            </rule>
        </rules>
    </rewrite>
 </system.webServer>

I need to move this to a section so that I can have seperate rules for QA, DEV and Production, what would be the "type that i would define in the section?

<configSections>
    <section name="IISURLRewriteSection" type="???"/>
</configSections>

Will the IIS automatically pick up these settings once moved outside from web.config to another custom config file?

JosefAssad
  • 4,018
  • 28
  • 37
Murtaza Mandvi
  • 10,708
  • 23
  • 74
  • 109

2 Answers2

0

The best solution, imho, would be to move the configuration details into external files, which you can then swap out per-environment.

This is pretty easy to do using the method described in Moving IIS7 url rewrite section out of the web.config file, where you would have something like this in your Web.config file:

<system.webServer>
    <rewrite configSource="rewrite.config"/>
</system.webServer>

Then you can store the environment specific stuff in a separate file, rewrite.config, looking something like this:

<rewrite>
    <rules>
        <clear />
        <rule name="Category URL" stopProcessing="true">
            <!-- ... --->
        </rule>
    </rules>
</rewrite>
Community
  • 1
  • 1
Owen Blacker
  • 4,117
  • 2
  • 33
  • 70
0

We resorted to writing our own HTTPModule since from debugging point of view as well any issues that would arise at IIS level would have to have the Operations team involved - just following a process defined in our org :)

Murtaza Mandvi
  • 10,708
  • 23
  • 74
  • 109