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!

0


a source to share


2 answers


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>

      

0


a source


I just read a post about saving routes to DB. This might help you:



ASP.NET MVC: Saving Routes in Database

0


a source







All Articles