I am trying to implement URL redirect for the website rather than doing it page by page. I want to do it in the global.asax file. Below is the code i have defined.
I
Building on previous correct and helpful answers, here are a couple specific examples. Assuming you want to delete the old page (as I did), there are a couple of options.
OPTION 1: Modify the Global.asax
void Application_BeginRequest(object sender, EventArgs e)
{
// Add permanent redirection for retired pages
if (Request.Url.LocalPath.ToLower().StartsWith("/[OLD PAGE NAME]"))
{
Response.RedirectPermanent("/[NEW PAGE NAME]", false);
}
}
OPTION 2: Modify the web.config