Congratulations to all monthly winners of May 2013 !!! They have won INR 2900 cash and INR 27497 worth prize.
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 19684 |  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: 6067 | Category: ASP.NET | Level: Beginner red flag

Advertisements

Advertisements
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.
Advertisements

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

In the process of developing an application, there are situations when you need to pass a particular value from user control to its calling page. This article describes solution to that type of problem in an easy to follow steps.

In this article we shall learn how to limit the maximum number of characters allowed in the Mult-iline textbox, how to avoid text wrapping into the Multi-line textbox, how to apply CSS style into the asp:TextBox and how to set the default focus on the TextBox when page loads.

Diagnosing a software application is an art and this art has to be more skillful when you go on production. In development environment you have the complete VS IDE tool so the diagnosing becomes much easier. On production environment as a best practice you do not install visual studio IDE. So on production it’s like fighting with the lion without a knife.

In this article we shall learn how to submit a page to the server when the TextBox value has changed, specify the width of the TextBox, specify the Maximum characters allowed for the TextBox, making the textbox readonly or disabled, and displaying multi-line textbox in asp.net.

This Article will describe the input / output (Request / Response) message formats.

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 find 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. | 6/19/2013 1:19:34 AM