views:

94

answers:

2

I'm loading a special set of routes form an XML file.

Those rotes must be created in my application for compatibility reason with the previous version of my application. Initially, the first version where wrote in .net 1.1, and I must create some routes to fully support "old" urls to the new ones. The application has been full rewrited with .NET 3.5+MVC.

My Problem is: Some old URLs can't be created as Routes from the XML file, since I can't specify the '?' character.

An example that ilustrates my problem is: "executeSearch.aspx?search=ferrari" That must redirect to "/search/ferrari.htm".

Those Rotes must be created dynamically from that XML file.

My actual code is executed in App_Start, reading an XML file and creating rotes that points to a common "redirector" controller, which just uses Response.Redirect to the destionation URL, pointed in the XML File.

Ok, my question: Is there anything I can do, or any way to specify the route attributes names dinamcally?

Thanks!

A: 

This is almost a carbon copy of another question I put an answer on...

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>
Dan Atkinson
A: 

I just read a post about storing routes in DB. It might help you:

ASP.NET MVC: Store Routes in the Database

CD