I am migrating a website that was once hosted on an Apache/Tomcat environment running JSP. We now have it converted to C# and moved to an ASP.NET platform.
So as not to affect our SEO rankings, how do I handle the old URLs? I can't seem to get this to work in global.asax.
For example, on the old site we have the following URL:
It now points to:
I've tried looking for the request URL in the global.asax file using either Application_Start() or Application_BeginRequest()
, but what happens is the 404 catches first and it just takes it to the 404 page. I can't seem to capture what the user has entered and then perform a 301 redirect on that page.
Any ideas? Attached is the code that DOESN'T work.
void Application_BeginRequest(Object sender, EventArgs e)
string strAbsolutePath = System.Web.HttpContext.Current.Request.Url.AbsolutePath.ToString();
string aAbsolutePath = strAbsolutePath.Split('/');
if (aAbsolutePath != null)
protected void RedirectExternal(string nURL)
// Perform a 301 Redirect.
Response.Status = "301 Moved Permanently";