Click here to Skip to main content
15,908,115 members
Articles / All Topics

Response New Function Named as Response.RedirectPermanent

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
29 Oct 2012CPOL3 min read 6.1K   1  
So what is Response.RedirectPermanent?

Overview

Recently, I came to know about the new function of Response named as Response.RedirectPermanent. So what is Response.RedirectPermanent? Where to use it? It's the same like Response.Redirect() function as it redirects you from one page to another but it returns HTTP status code 301 as compared to HTTP 302 returned by response.redirect(). So, in this article, we would have a brief overview of Response.RedirectPermanent.

Response.RedirectPermanent

Consider a following scenario: We have a web application which sells products to end users. In order to increase the user count or to bring more users to the website, the company decides to start with discounts on certain products. Hence, it introduces the new page named as Discount.aspx listing all the products which has discounts on them. When user clicks on any of the discounted products, website redirects the user to page named as Products.aspx where user can view the details of product. In order to increase the revenue, company hires the SEO and registers the page on different search engines like Google, Yahoo, etc. Hence, discount page gets registered on different search engines.

Now, after some months, the company decides that it don't want to give discounts on the products and thinks of removing the page. But they don't want to lose their customers who were coming to their site through the discounted page.

In this case, we have two options:

Disadvantage: When search engines see the same data on both discounted and products page, they can penalize the site for having the duplicate content and would delist the site.

Disadvantage: When we use response.redirect, then it returns the status code as HTTP 302 temporarily redirected to different search engines. So, search engines store this information in their table that this discounted page had returned status code HTTP 302 and it was temporary re-directed.

  1. Copying the content of products page to discounted page
  2. Use Response.Redirect: We can use Response.Redirect on the page load of discounted page which would redirect the user to products page.

Search engines expect that the next time when we would hit the discounted page, it would show the data and shouldn't return 302 status code. If next time again, page returns status code 302 then search engine penalizes the site and would delist the site. Hence, in this scenario, we should always use Response.RedirectPermanent. What does Response.RedirectPermanent do?

When we use Response.RedirectPermanent, then it returns status code HTTP 301 Moved Permanently. It tells different search engines this page has permanently moved to new page. By this, different search engines update their index with a new page. So, the next time if someone clicks on the discounted page, user would be automatically directed to products page by search engines. So, let's build a small application, which would have  two buttons - one button would use Response.Redirect and the other button would use Response.RedirectPermanent. We can view the GET request details by using the tool named as HTTPDebugger. Below are the GET requests. You can see that when we use Response.Redirect, then browser has returned status code as 302 Found; however in case of Response.RedirectPermanent, status code returned is 301 Moved Permanently.

Below is the screenshot:

Conclusion

Whenever we want to remove any page from website, we should always use Response.RedirectPermanent. With this, we wouldn't lose our customers directed to our site through different search engines. Hope with this article, you got a brief overview of Response.RedirectPermanent.

This article was originally posted at http://varunkhanna.blogspot.com/feeds/posts/default

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
Please visit my blog http://varunkhanna.blogspot.com/ to read more articles

Comments and Discussions

 
-- There are no messages in this forum --