In my previous article, I’ve explained difference between Response.Redirect and Server.Transfer in ASP.NET. You can also see list of ASP.NET FAQ. In this article, I am going to explain difference between Response.Redirect and Response.RedirectPermanent. First of all I am going to explain difference between HTTP response Status Code 301 and HTTP response Status Code 302.
A complete list of HTTP status codes can be found at Wikipedia.
In .NET 4.0, Microsoft has introduced some improvements related to Search Engine Optimization (SEO). SEO is most important for a digital marketing websites. A huge percentage of traffic to sites now comes from different search engines like google or bing. It is very common behavior within web applications to move pages or resources and other content around over time, which can lead to an accumulation of outdated links in search engines. To overcome this issue and to enhance SEO of websites, Microsoft has introduced Response.RedirectPermanent method in.NET 4.0. The main objective of this method is to indicate correct HTTP response status code to search engine. The Response.Redirect returns HTTP response status code as 302 whereas Response.RedirectPermanent returns HTTP response status code as 301.
What is HTTP response status code?
Whenever a user accesses web page in a web browser (client) or Google (or any other search engine like Bing) crawls the web page for rebuilding its search index, a request is made to web server for processing the web page. The web server returns an HTTP status code in response to the request. This status code provides relevant information about the status of the request. This status code also gives Googlebot information about web site and the requested page. Below are the most common status codes:Code | Description |
---|---|
200 | Page or resource has been found successfully. |
404 | Requested Page or resource does not found. |
503 | Server is temporary unavailable. |
301 | Permanent Redirect. The requested page has been permanently moved to a new location. |
302 | Temporary Redirect. the requested page is temporarily located somewhere else. |
In .NET 4.0, Microsoft has introduced some improvements related to Search Engine Optimization (SEO). SEO is most important for a digital marketing websites. A huge percentage of traffic to sites now comes from different search engines like google or bing. It is very common behavior within web applications to move pages or resources and other content around over time, which can lead to an accumulation of outdated links in search engines. To overcome this issue and to enhance SEO of websites, Microsoft has introduced Response.RedirectPermanent method in.NET 4.0. The main objective of this method is to indicate correct HTTP response status code to search engine. The Response.Redirect returns HTTP response status code as 302 whereas Response.RedirectPermanent returns HTTP response status code as 301.
Difference between Response.Redirect and Response.RedirectPermanent and Server.Transfer
Suppose, you are having two pages: Page1.aspx and Page2.aspx.- Response.Redirect: Response.Redirect will redirect request from Page1.aspx to Page2.aspx. Response.Redirect() method returns HTTP response status code 302 Found (temporary redirect) response, which results in an extra HTTP round trip when users attempt to access the old URL. So whenever search engine will try to crawl your website, it will not update its search index database and will keep old page URL into search index database because of HTTP response status code 302 which indicates that resource has temporarily moved to another location. This means that using a temporary redirect can negatively impact page ranking.
- Response.RedirectPermanent: Response.RedirectPermanent will redirect request from Page1.aspx to Page2.aspx and return HTTP response status code 301 (permanent redirect). So whenever search engine will try to crawl your website, it will update its search index database and use the new URL to rebuild search index. Thus your search engine page ranking will improve.
- Server.Transfer: Server.Transfer will transfer request from Page1.aspx to Page2.aspx and return HTTP response status code 200 (Page found). Search Engine will be unaware of any redirection which took place between Page1.aspx and Page2.aspx and will keep Page1.aspx to its search index database. In Server.Transfer, web browser URL doesn’t get changed. Please check more for Server.Transfer.
How to monitor HTTP response status code?
You can monitor HTTP response status code by using various website traffic monitoring tool. One of the best tools to monitor website traffic is FIDDLER. Fiddler is a free web debugging proxy which logs all HTTP(s) traffic between your computer and the Internet. Use it to debug traffic from virtually any application that supports a proxy like IE, Chrome, Safari, Firefox, Opera, and more.
- Response.Redirect: Create Page1.aspx and Page2.aspx in your web application. In Page_Load of Page1.aspx, write below code to redirect from Page1.aspx to Page2.aspx. Browse Page1.aspx and monitor traffic using FIDDLER.
protected void Page_Load(object sender, EventArgs e) { Response.Redirect("Page2.aspx"); }
- Response.RedirectPermanent: Create Page1.aspx and Page2.aspx in your web application. In Page_Load of Page1.aspx, write below code to redirect from Page1.aspx to Page2.aspx. Browse Page1.aspx and monitor traffic using FIDDLER.
protected void Page_Load(object sender, EventArgs e) { Response.RedirectPermanent("Page2.aspx"); }
- Server.Transfer: Create Page1.aspx and Page2.aspx in your web application. In Page_Load of Page1.aspx, write below code to transfer from Page1.aspx to Page2.aspx. Browse Page1.aspx and monitor traffic using FIDDLER.
protected void Page_Load(object sender, EventArgs e) { Server.Transfer("Page2.aspx"); }
0 comments :
Post a Comment