(Mis)Using App_LocalResources?
The migration process itself produced us a mapping of old Ids and new Ids, so all I needed was something that enabled me to plug in the old Id and generate the new URL to issue a 301 redirect at. I wanted the change to be as localised as possible, and didn't want to do anything that impacted the functionality of the existing editorial site. After a bit of head-scratching, I decided to make use of a resx file, specifically a local resx file by creating an App_LocalResources folder, and creating a new .aspx.resx file. I populated the resx file with a name value of the Old Id, and a value value of the New Id, and the look-up became straightforward. All I needed to do was catch the Old Id, wrap a
newId = GetLocalResourceObject(oldId.ToString()).ToString();
in a try/catch in case the old Id isn't in the resx file and that would do it. I built up a new url and issued a 301 redirect via
Response.Status = "301 Moved Permanently"; Response.AddHeader("Location", UriToNewId);
All of this code replaced the original code on the editorial site, and redirected any visitors to the new jobs site.