views:

459

answers:

2

I am moving from an old site design to a new design with new URL's.

All previous page names were static files called PageXX.html, PageX.html, Index.html - where X is a number.

My site is now dynamic but I want to trap for those 3 incoming url's and then try and redirect to a certain new page (301 Redirect) else send them to the home page.

Do I do all of this in Global.asax or do I just trap those Url's in Global.asax and then route it to a Action and do a 301 Redirect in the Action?

Any code examples would help a lot!

Thanks

EDIT: I think what needs to be done is trap the routes in Global.asax and then send them to a Action which will work out where to send the user ie. a similar page on the new site else I will send to the home page.

+1  A: 

That's right, just do it in your routes configuration (usually in global.asax). You can set these up as static special cases.

routes.MapRoute("Page3", 
            "SomeURL/Page3.html",
            new { 
                  controller = "SomeController",
                  action = "SomeAction",
                  page = "2"
                });
UpTheCreek
A: 

For PageXX.html, PageX.html, Index.html pages you can do regular expression based matching too. That will allow you to maintain the whole thing with a single route mapping.

Rahat