Creating a dynamic route through the Xml file
I am loading a custom set of routes from an XML file.
These genes must be generated in my application for compatibility reasons with the previous version of my application. Originally the first version where is written in .net 1.1 and I have to create multiple routes to fully support the "old" urls for the new ones. The app has been completely rewritten with .NET 3.5 + MVC.
My problem: Some old urls cannot be generated as Routes from XML file since I cannot specify '?' character.
An example to illustrate my problem: "executeSearch.aspx? Search = ferrari" This should be redirected to "/search/ferrari.htm".
These companies should be dynamically generated from this XML file.
My actual code is executed in App_Start, reads the XML file, and generates genes that point to a generic "redirector" controller that simply uses Response.Redirect for the dispatch URL specified in the XML file.
Ok, my question is, is there anything I can do, or any way to specify route attribute names dynamically?
Thanks!
This is almost a copy of another question . I'll answer...
How about an IIS redirect route instead?
<rule name="Redirect Search" stopProcessing="true">
<match url="^executeSearch.aspx?search=(.*)$" />
<action type="Redirect" url="/search/{R:1}.htm" redirectType="Permanent" />
</rule>
a source to share