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.

Gunnar Peipman

Gunnar Peipman is ASP.NET, Azure and SharePoint fan, Estonian Microsoft user group leader, blogger, conference speaker, teacher, and tech maniac. Since 2008 he is Microsoft MVP specialized on ASP.NET.

    10 thoughts on “ASP.NET 4.0 SEO features: Response.RedirectPermanent()

    • May 8, 2010 at 4:33 pm
      Permalink

      also:
      Response.Clear();
      Response.Status = “301 Moved Permanently”;
      Response.RedirectLocation = PathOrUrl;
      Response.End();

    • July 26, 2010 at 3:17 pm
      Permalink

      Because it sends out response to client. Not every HTTP request ends up with response that is shown to user as page. 301 and 302, by example, return header called Location that contains URL of page where client should go instead.

      302 is temporary redirect and that means that resource may be soon available in current address again. So, client has to check it always when the request is made. 301 is permanent redirect that tells client that resource is moved to another address and it will not be available on current address ever again.

      One of those clients is your browser and the other one is search engine spider. The last one doesn’t like those 302 responses and that’s why RedirectPermanent is important.

    • July 26, 2010 at 9:49 pm
      Permalink

      Response.RedirectPermanent() is server side mechanism then how it’s work for SEO ?

    • May 5, 2011 at 11:33 am
      Permalink

      Thanks to expose nice feature of .net 4.0.

    • July 4, 2011 at 10:42 am
      Permalink

      nice information but i have one question can one told me what happen if we used redirectpermanently.
      will it effect on search engine pages that it index ?

      what happen if we redirect paramently that page that Google index ? Page index remain or removed from the google.

      any told me ?

      thanks in advance

      yasir butt

    • September 23, 2011 at 7:58 pm
      Permalink

      It is good that we have this option available to redirect.

      I was looking to redirect all “non www” urls to “www urls”. Can we do this at the server level(IIS 7 available available through websitepanel) itself or this is the only way available?

    • January 4, 2012 at 5:22 am
      Permalink

      This is a really good read for me. Must admit that you are one of the best bloggers I have ever read. Thanks for posting this informative article.love it.

    • January 22, 2012 at 10:33 pm
      Permalink

      Hello! Just want to say thank you for this interesting article! =) Peace, Joy.

    Leave a Reply

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