Skip to main content

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();

Popular posts from this blog

Merging multiple PDFs using iTextSharp in asp.net c#

In this article i will show you how to merge multiple pdfs into one using ITextSharp below is the two approach one is to pass your input files path, output file path (will be created if not exist) and another is pass direct input stream, output stream and it will write the merge files into output stream.

how $document.ready() is different from window.onload()

we often use window.onload() in javascript and $document.ready() in jquery and assume that both are same just jquery library wrap up javascript window.onload() and introduce $document.ready() but no there is much difference between them below is the explanation -

Uploading large file in chunks in Asp.net Mvc c# from Javascript ajax

Often we have a requirement to upload files in Asp.net, Mvc c# application but when it comes to uploading larger file, we always think how to do it as uploading large file in one go have many challenges like UI responsiveness, If network fluctuate for a moment in between then uploading task get breaks and user have to upload it again etc.

Scrollable Gridview with fixed headers in asp.net

horizontal and vertical scrollable Gridview with static header row.fixed header in gridview in asp.net.static header in gridview through java script.I was looking for a solution for this for a long time and found most of the answers are not working or not suitable for my situation i also find most of the java script code for that they worked but only with the vertical scroll not with the horizontal scroll and also combination of header and rows doesn't match.

How to handle click event of linkbutton inside gridview

Recently I have posted how to sort only current page of gridview, Scrollble gridview with fixed header through javascript, File upload control inside gridview during postback and now i am going to explain how to handle click event of linkbutton or any button type control inside gridview.

We can handle click event of any button type control inside gridview by two way first is through event bubbling and second one is directly (in this type of event handling we need to access current girdviewrow container)