I upgraded Dvdcrate.com to be ASP.NET MVC and one of the problem is the old pages are indexed by search engines and being served on search results. So I have the old *.aspx page that I need to fix up and send along to the MVC page.
An example of the page in the search database;
And I need it to go to the new MVC controller and action like this;
So I did it this way, I put this in the Global.aspx.cs file;
protected void Application_BeginRequest (object sender, EventArgs e)
var requestUrl = Request.Url.ToString().ToLower();
var equalPos = requestUrl.LastIndexOf("=") + 1;
var upc= requestUrl.Substring(equalPos, requestUrl.Length - equalPos);
Context.Response.StatusCode = 301;
Context.Response.Redirect("/Media/Detail/" + upc);
Probably not the most elegant, but it does work.