views:

71

answers:

1

I'm working on migrating an existing ASP.NET web site into an MVC project. There are several (60+) pages that I don't want to rewrite just yet, and so I'm wondering if there's a way that I can:

  • Move the existing .aspx pages (both markup and code-behind files) into a 'Legacy' folder in my MVC structure
  • Set up routing so a call to /foo.aspx (without 'legacy') will actually invoke ~/Legacy/foo.aspx

Effectively, I don't want "legacy" in the URL, but I also don't want the MVC solution to be full of legacy .aspx pages. I accept that this is a very minor point, I'm just curious if it can be done with Routing.

I realize I could do:

routes.MapPageRoute("legacy-foo", "Foo.aspx", "~/Legacy/Foo.aspx"); 

but I'm wondering if there is a way to do that dynamically (using MVC routes)? eg:

routes.MapPageRoute("legacyroutes", "{filename}.aspx", "~/Legacy/{filename}.aspx"); 

I guess one way is to use a URL rewriter module, but that seems a bit redundant if routes is capable of doing this natively.

A: 

Using the IgnoreRoute method suggested at:

http://haacked.com/archive/2008/07/14/make-routing-ignore-requests-for-a-file-extension.aspx

Erik Philips
Sorry not quite what I meant: I don't want to just ignore processing of .aspx, I want to have the .aspx files in a subfolder of my solution, but I don't want that subfolder to show up in the URL. Updated the question to clarify.
gregmac