What is 301 permanent and 302 temporary http status code redirection and how to implement it in asp.net c#

This article explains what is the http status code 301 and 302, 301 status code vs 302 status code, how to use it and how to implement it in your asp.net c# website.

Explanation 301 permanent and 302 temporary http redirects -

Http Status 301 means that the current resource (webpage) is moved permanently to a new location means webpage is no longer exists in the server.

Http Status 302 means that the current resource (webpage) is temporarily located somewhere else, means this is only conditional redirect, webpage is still alive in server and may reestablish.

Http Status Code 301 explanation figure diagram in seo point of view
Status 301 explanation figure diagram in seo point of view 

Impact in SEO and Search Engine Spider (Google, Bing, Yahoo etc.) -

When a search engine spider founds 301 status code in response header of a webpage, it understand that this webpage is no longer exist, it searches for location header in response pick the new URL and update the indexed URL with the new one and also transfer pagerank.

So search engine updates all indexed URL that is no longer exist (301 found) with the new URL, this will retain your old webpage traffic, ranking of the page, pagerank and divert web traffic to the new URL (you will not lose your traffic of old webpage).

Browser: if a browser founds 301 status code then it caches the mapping of original URL with the new URL, the client/browser will not attempt to request the original location but use the new location from now on until cache remove.

Explaination of 301 http status code permanent


When search engine spider founds 302 status for a webpage, it will only redirect temporarily to the new location and index both of the page, old webpage URL still exists in search engine database and it always attempt to index the old location, the client/browser will still attempt to request the original location.


Explaination of 302 http status code permanent

Implementation of 301, 302 http redirection in asp.net c# -

Both given method is same Response.RedirectPermanent internally works as same as another one.
Response.RedirectPermanent("about.aspx");

//******Or Use This Both Are Same **********
Response.Clear();
Response.StatusCode = 301;
Response.RedirectLocation = "about.aspx";
Response.End();

Both given method is same Response.Redirect internally works as same as another one.
Response.Redirect("about.aspx");

//******Or Use This Both Are Same **********
Response.Clear();
Response.StatusCode = 302;
Response.RedirectLocation = "about.aspx";
Response.End();