Wildcards with ASP.NET MVC MapPageRoute to support organizing legacy code -


I am working to migrate an existing ASP.NET web site to an MVC project. There are many (60+) pages that do not want to rewrite yet, and so I'm thinking that there is a way I can:

  • Existing .aspx pages (Setting up routing in my MVC structure)
  • Set up routing, so call /foo.aspx (without 'legacy') will actually call ~ / Legacy / foo .aspx

Effectively, I do not want "inheritance" in URL, but I also do not want that MVC solution I am sure that this is a very small case, I am curious if it can be done with routing.

I know that I can do it: / P>

  routes.MapPageRoute ("legacy-foo", "fu espx", "~ / legacy / fu espx");  

Is there any way to dynamically (using MVC routes)? Example:

  Routes. MapPageRoute ("Legsirounds", "{filename} .aspx", "~ / Legacy / {filename} .aspx " );  

I think there is a way to use a URL rewriter module, but it seems that something is unnecessary when being able to route the route.

I have solved this using a controller which returns the content of the file. This is not a perfect and fast solution, but it works.

  routes MapRoute ("legacyroutes", "{filename} .aspx", new {controller = "home", action = "redirectfile"}); Public Controller {Public actionResult RedirectFile (String Filename) {string url = Url.Content ("~ / Legacy /")  

and Controller:

  "+ Filename +" .aspx "); (URL) redirect; // Other code to process the file}}  

Details and other examples are here:


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -