This Tutorial will cover how to create a Permanent Redirect in ASP.NET 4.0

Introduction

This guide will show you how to create a permanent redirect for one of your ASP.NET pages in 3 easy steps. A permanent redirect is important for search engines because it will let the crawlers know that the old site is no longer available (by throwing a HTTP 301 exception) letting it know to go to the new page from then on.

Step 1: Creating the “Old Site”

We can start by creating a website to pose as our old website that is going down. So create a New Web Form called “OldSite.aspx” and insert some text or copy the code from below.

Step 2: Creating the “New Site”

Now that we have the old site we need to Create the “New Site” that will be taking it’s place. So create another New Web Form and call it “NewSite.aspx”. Insert some Text or Copy the Code form below.

Step 3: Creating the Permanent Redirect

Now that we have Both of our Sites we can insert some c# code to let the Search Engine Crawlers know that we are initiating a Permanent Redirect.

Conclusion

Now run your project and attempt to go to the oldsite.aspx page. If it is working correctly you should be directed to the Newsite.aspx page immediately. The reason we use Response.RedirectPermanent and not just Response.Redirect is because we want the Search Engine crawlers to know that the OldSite.aspx is down permanently and we will no longer be using that. This will allow them to change old static web links to the OldSite.aspx page and redirect them on their end.

Optional

If you want a temporary redirect use the following line of code instead.

Download Source Files