I am converting an old ASP.NET WebForms app to ASP.NET MVC 4. Everything is fine, except that I have a need to maintain backward compatibility with a specific URL. I found this great post on using UrlRewrite, but sadly that isn’t something I can count on (this app gets deployed to lots of servers). At the bottom, he mentions using routing if you only have a small set of URLs to deal with, but doesn’t provide any example.
Since I only have one url to deal with, I think routing would be the simple approach, but I’ve never dealt with anything except the default route /Controller/Action/{id} so I am looking for a solution that
- Has no external dependencies
- Will work on old crappy browsers
- Doesn’t matter if my app knows about this old url or not
The Old URI
https://www.mysite.com/default.aspx?parm1=p1&parm2=p2&etc=soforth
The New URI
https://www.mysite.com/Home/Index/?parm1=p1&parm2=p2&etc=soforth
Background: this app gets deployed to lots of servers at different locations. There are other apps (that I cannot update) that display the “Old URI” in a web-browser control, so I need them to continue to work after the app is updated to asp.net mvc.
Something like following should work (untested, may need to make this route to be one of the first):