Saturday, August 14, 2010

Response.RedirectPermanent

Scenario
Consider that you have created a page named "offers.aspx" which has some item listings and free offers to users when they buy the items.

After the offer has expired you want redirect all the web traffic from "offers.aspx" to "listings.aspx".

If you use Response.Redirect("listings.aspx") in the offers.aspx then it returns a HTTP 302 status to the browser meaning that the "Resource is temporarily moved to another location". This 302 status informs the search engines that the offers.aspx page is temporarily moved. If it returns the same status whenever the search engine crawls, it will ignore the URL for duplicate content.

Solution
To avoid this problem and to improve Search Engine Optimization (SEO) .NET 4.0 has got a new method for performing redirections.

Response.RedirectPermanent("listings.aspx")

This will return a HTTP 301 status "Moved Permanently" to the browser. Because of that the search engine when it crawls the next time will update its URL list.

Alternatively the same can be achieved with .NET 3.5 as mentioned below.

Response.Status = "301 Moved Permanently";
Response.RedirectLocation = "listings.aspx";

No comments:

Post a Comment