different in Response.RedirectPermanent method and Response.Redirect
ets say that I have a page called "page1.aspx", and google cached it in his database search, now if I changed the page1.aspx or I removed it, then I need to put the Response.RedirectPermanent("Page2.aspx) in the page load of Page1.aspx, so that google next time will know that Page1.aspx has become Page2.aspx.
In the backend, http protocol supports 2 ways of redirections, 301 and 302. Permanant redirect send 301 response code to the browser
"301 redirects are permanent. They mean that the page has moved, and they request any search engine or user agent coming to the page to update the URL in their database. This is the most common type of redirect that people should use."
Response.RedirectPermanent do the same thing as following code does.
Response.Status = "301 moved permanently";
Response.AddHeader("location", newPath);
Response.End();
Response.RedirectParmanent
is an extension function introduced in .NET 4.0.
The main motive of it is to indicate the Response Code to the Search Engine that the page is moved permanently. The
Response.Redirect
generates Response code as 302 whereas
RedirectParmanent
returns 301.
Thus say you have a page, and which is included to search engine for a long time, if you use
Response.Redirect()
it will not change this effect to the search engine(taking this a temporary change), while if you use
Response.RedirectParmanent
()
it will take it as permanent.
In case of
Server.Transfer()
the actual response is actually been updated. There is no effect to the search engine, and search engine will think the output is coming from the same page that is called upon. Let us give an example :
Say you have 2 pages (Page 1 and Page 2) where Page1 redirects to Page2
In case of
1.
Response.Redirect()
: Search Engine will take this redirection as Temporary(Status 301) and always keep Page1 in its cache.
2.
Response.RedirectParmanent
()
: Search Engine will take this a permanent redirection(Status 302) and will remove Page1 from its database and include Page2 for better performance on search.
3.
Server.Transfer()
: Search Engine will be unaware of any redirection been took place (Status 200) and will keep Page1 to its database. It will think Page1 is producing the output response of Page2.
When to use:
Response.Redirect
is perfect when your page is temporarily changed and will be changed to original within a short span of time.
Response.RedirectParmanent
()
when you are thinking of deleting the Page1 totally after the search engines changes its cache.
Server.Transfer()
when you are thinking of keeping the page for ever, and to let search engine unaware of this redirection.
Comments
Post a Comment