I believe that if you specify the following routes:
routes.MapRoute( null, "Bar/{action}/{id}", new { controller = "Bar", action = "View", id = UrlParameter.Optional }, new { action = "Index|Next" } //contrain route from being used by other action (if required) ); routes.MapRoute( null, "Foo.aspx/{id}", new { controller = "Bar", action = "View", id = UrlParameter.Optional } ); //specify other routes here for the other legacy routes you have.
Then this should solve your first problem. If the user specifies Foo.aspx in the URL, they will be migrated to the View action.
If the action link:
@Html.ActionLink("Click me", "Index", "Bar")
then the first route will be used (as it matters).
However, I could not figure out how to indicate if Foo.aspx?id=...
then go to one else route if Foo.aspx
is specified and then go to another route. So I would check if id is equal in action. However, if you find out, I would love to know.
Hope this helps.
source share