I have a redirect mapping file called RedirectMapping.config. It has the following format:
<rewriteMaps>
<rewriteMap name = "StaticRedirects">
<add key="/newsstand/" value="/publications/articles/" />
<add key="/careers/" value="/careers/business-professionals/" />
</rewriteMap>
</rewriteMaps>
This file is pointed to in my web.config file as follows:
<system.webServer>
<rewrite>
<rewriteMaps configSource="RedirectMapping.config"/>
<rules>
<rule name="Redirect rule">
<match url=".*" />
<conditions>
<add input="{StaticRedirects: {SCRIPT_NAME}}" pattern="(.+)" />
</conditions>
<action type="Redirect" url="http://localhost{C:1}" appendQueryString="false" redirectType="Permanent"/>
</rule>
</rules>
</rewrite>
</system.webServer>
I need to read the key value pairs from the RedirectMapping.config file at the run time. How is this possible in .Net? Is there any API available to do it or I have to make such API?