How to 301 redirect old URLs from a JSP site to an ASP.NET site?

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[1] != null)
            switch (aAbsolutePath[1])
                case "programs":
                    //do nothing
protected void RedirectExternal(string nURL)
        // Perform a 301 Redirect.
        Response.Status = "301 Moved Permanently";
        Response.AddHeader("Location", nURL);

Open in new window

Who is Participating?
cacklebunnyConnect With a Mentor Author Commented:
Since no answer is forthcoming, I've researched and found an ISAPI plugin that looks like it will achieve what I want.
cacklebunnyAuthor Commented:

Thanks for the links.  Unfortunately, these pages reflect rudimentary tutorials and explanations about what a 301 redirect is and 301 best practices, both of which I'm already familiar.  They do not address my specific issue.

Thanks again.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.