Introducing DotNetFunda.com on mobile http://m.dotnetfunda.com ! Be with DotNetFunda.com on the go !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 4537 |  Welcome, Guest!   Register  Login
Home > Articles > ASP.NET > ASP.NET 4.0 Features : Page RedirectParmanent

ASP.NET 4.0 Features : Page RedirectParmanent

1 vote(s)
Rating: 1 out of 5
Article posted by Abhi2434 on 3/1/2010 | Views: 4416 | Category: ASP.NET | Level: Beginner red flag


The article discusses one of the new feature introduced with .NET 4.0 which enable you to Redirect your page for Search Engine

Introduction
.NET 4.0 introduces a new concept to redirect your page from one location to another.  From the early days, you have been using Response.Redirect / Server.Transfer. While Server.Transfer doesnt seem to send any information about redirection to search engine, Response.Redirect redirects a page and sends 302 as its response Code. The response code 302 identifies that the transfer is a temporary and therefore, the Search Engine entry will never be updated. But in certain cases when you require the search page to redirect it permanently. You might want the search result to show the new page rather than the old page which redirects to the new page. Here lies the requirement of this new method Response.RedirectParmanent.





Main Objective of Response.RedirectParmanent
Response.RedirectParmanent works in similar fashion as to Response.Redirect. The only difference is its Response code.

Method                      Response Code                  Meaning

Redirect()                  302                                  Response is Redirected temporarily and Search Engine Doesn't need to change its entry
RedirectParmanent()    301                                  Redirect is parmanent, and Search engine will update the old entry with the new one.
Server.Transfer()        200                                  No redirection code is sent, and Search Engine will think the response is coming from the same page.

From the above table, it is clear that Search engine will only update its entry when we use RedirectParmanent.

Implementation
You must know that this method is introduced in ASP.NET 4.0, so if you are in previous version, you can use :

public static class Extensions
{
public static void RedirectPermanent(this HttpResponse Response,
string absoluteUri)
{
Response.Clear();
Response.Status = "301";
Response.RedirectLocation = absoluteUri;
Response.End();
}
}

This Extension will add the RedirectParmanent to your application.

Usage

  • Response.Redirect is perfect when your page is temporarily changed and will again be reverted to original within a short span of time.
  • Response.RedirectParmanent() when you are thinking of deleting the original page totally after the search engines changes its database. 
  • Server.Transfer() when you are thinking of keeping the page for ever, and to let search engine unaware of this redirection.

Conclusion
To Conclude, I must be thankful that the method is added permanently to the Framework. Hence, I dont need to write my own extension. Use it gracefully and only when it is required. There are lots of other features as well, I hope I would try to discuss each of them in my next series of articles.

Thanks for Reading.

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

About Abhishek Sur

Experience:3 year(s)
Home page:http://www.abhisheksur.com
Member since:Wednesday, December 02, 2009
Level:Silver
Status: [Member] [Microsoft_MVP] [MVP]
Biography:Working for last 2 and 1/2 years in .NET environment with profound knowledge on basics of most of the topics on it.
 Responses
Posted by: Rajni.Shekhar | Posted on: 09 Apr 2012 06:28:40 AM | Points: 25

Hi,
Nice article, i have tried it in 3.5
but it is showing run time error: "HTTP status string is not valid." at the line : response.Status = "301";

Please suggest.

>> Write Response - Respond to this post and get points
Related Posts

I am writing this article to check how the cache of a page works in a website. I shall show all the details with example.

This article shows how to pass values from one page to another page without state management techniques like Session , Query string , cookies etc..

Here i have tried to discuss Master Page handling concept in details.

One cause of slow loading web pages is the time taken to load the JavaScript, CSS and image files. The software described here makes it very easy to reduce that time in any ASP.NET web site. It does this by minifying and combining the JavaScript and CSS files, optimizing browser caching, and much more. Installing and configuring the software is very easy for any site, and is described in detail in this article.

This Interview Questions is Part 2 and it will give you a quick start for two report giant’s crystal and reporting services.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2012 7:51:53 AM