ASP.NET 4.0 SEO features: Response.RedirectPermanent()

ASP.NET 4.0 introduces some SEO improvements. Response has now new method calledRedirectPermanent(). This method performs same redirect as Response.Redirect() but it uses response code 301. You can find more information about HTTP response codes from HTTP 1.1 specification, chapter 10. Status Code Definitions.

Response.Redirect() returns 302 to browser meaning that asked resource is temporarily moved to other location. Permanent redirect means that browser gets 301 as response from server. In this case browser doesn’t ask the same resource from old URL anymore – it uses URL given by Location header.

To illustrate difference between Response.Redirect() and Response.RedirectPermanent() let’s look at simple example. We need one usual ASP.NET Web Application with Global.asax file. In Global.asax file we have to implement BeginRequest() method.


protected void Application_BeginRequest(object sender, EventArgs e)
{
   
if (Request.FilePath == "/our-products.aspx"
)
    {
        Response.Redirect(
"/products.aspx", true
);
    }
   
if (Request.FilePath == "/about-us.aspx"
)
    {
        Response.RedirectPermanent(
"/about.aspx", true);
    }
}

Now let’s run our web application and make the following requests:

  • /our-products.aspx
  • /about-us.aspx

In both cases we will be redirected but redirections are different. Here is my little mix of FireBug outputs for these requests and I think it is very self describing.

Responses

Response.RedirectPermanent() has also overload with one parameter, just like Response.Redirect() does. If you have pages that exist in search engines but are moved to other location in your application then Response.RedirectPermanent() helps you build redirection controlling mechanism that likes to search engine spiders.


Leave a Reply

Your email address will not be published. Required fields are marked *