Tips, Tricks, Thoughts & Ideas

Page Permanently Moved - Status 301 vs. 302 

Friday, January 01, 2010 5:04:00 AM

Happy New Year!  Since this is the first day of the new year, I thought I would quickly talk about something new in .NET version 4.0. 

Response.Redirect() gives the browser the status code of 302.  This tells the browser that the requested resource is temporarily moved to another location.  A permanent redirect returns a status code of 301.  In this case browser, or more importantly the search engine spider, doesn’t ask for the old URL anymore.  Instead the new URL is what will be used in the future.  The other item to note is that most search engines will not follow a status code of 302 (redirect), but will follow a status code of 301 (permanently moved).  Thus, for SEO uses, when pages are moved or deleted, your system should use the status code of 302 to indicate the new location and not have the page removed from the indexing. 

In ASP.NET, prior to version 4.0, we used to have to do this in three lines:

        Response.Redirect("default.aspx", true);
        Response.StatusCode = 301;
        Response.End();

Now with ASP.NET 4.0, we can simply use the new method, which sets the status code for us.

        Response.RedirectPermanent("/about.aspx", true);
 



Comments are closed on this post.
   
Printable View © 2001 - 2010 JBC Digital, Inc. Site and Design by JBCDigital, Inc.