"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Saturday, September 24, 2011

Response.RedirectPermanent in asp.net

It is continuous process to either move web pages or content in Web Application development over the years. Search Engine Optimization and page hit count, getting more traffic for the website is the most important things in day today, moving pages or ceasing pages might not find the new page hits in search engines.

For example: Imagine that you have categories of products in your E-Commerce web application. When the old categories are replaced or updated by new categories, each year a page in your site might be replaced or updated accordingly. If any external sites (or even internal pages) have links to the category of these web pages in your web application, when link is clicked for the next time then it would have thrown error.

You would typically use Reponse.Redirect to suppress the error. But this is a manipulation, not actual work. This will work for the visitor but it internally 302 redirect.

Response.Redirect
In previous versions of ASP.NET we are using Response.Redirect that redirects to HTTP 302 found status response in turn redirects the page URL temporarily to the specified page URL. This is extra overhead to the server, performance hit here.

Problems
1. There is a round trip here.
2. 302 redirect is temporary redirect for the page.
3. No Search Engine Optimization (SEO) benefits due to this approach
4. You are neither informing search engine to updated internal indexes nor pass old page rank to new page.

Solution: Issuing permanent HTTP 301 redirect will solve the purpose, directly available in ASP.NET 4.0

Importance of HTTP Response Code 301:
This happens to move some WebPages or entire website from one domain to another or change the URL of some of the pages inside the website most of the time. This is quite difficult for a webmaster who deletes the pages from the old server, maps them to the new domain. In this case webmaster looses SEO that is related to previous links. In order to prevent SEO loss we need to make use of 301 Redirects.
HTTP Response Code 301 instructs the browser that the particular page has been moved permanently from the old location to the new location. The benefit of using 301 Redirects is that the search engine, crawlers store SEO information related to the old link based on 301 redirects. It also informs the search engines that the page location has permanently moved and it needs to index the page from the new location in future. This is really useful for search engines like Bing or Google that will carry over page rank to the new page if this status code is seen.

Response.RedirectPermanent
It’s the method of Page.HTTPReposne class that permanently redirects a requested URL to specified URL and issue HTTP 301response code Moved permanently responses. It uses the URL given by the location header. Unnecessary round trip for the browser is eliminated using this feature. This is used in migrating websites from old domain to new domain especially. As inbound traffic is important for significant usage of the web application this option is very much useful in live web applications as the requested URL is permanently redirected to some location using this mechanism. Since the redirection is HTTP 301 response status, search engine knows the new link that is redirected and results in the redirect.
Syntax :

Response.RedirectPermanent("/newlocation/oldcontent.aspx");

 Stay Tune...
 Have a nice day... 'N happy Coding :)

No comments: