Welcome to Professional ASP.NET - Chris Love's Official Blog Sign in | Join | Help

Chris Love's Official ASP.NET Blog

Chris Love's Helpful tips, tricks and pragmatic development knowledge for the ASP.NET world.
Add to Technorati Favorites


ASP Insider Follow Me On Twitter
301 Redirect ASP.NET

This will have to be part one of two entries.  I am about to start migrating a few rather large DotNetNuke sites to ASP.NET 2.0 and I want to make sure that any links people have to the pages are handled corrrectly.  The best way I think to do this is the set up a 301 Redirect handler, of course using URLMapping, but to let the search engines know it has been redirected, I need to pass the 301 code and the new URL to the spider.

301 redirect is the most efficient and Search Engine Friendly method for webpage redirection. It's not that hard to implement and it should preserve your search engine rankings for that particular page. If you have to change file names or move pages around, it's the safest option. The code "301" is interpreted as "moved permanently".

You can Test your redirection with Search Engine Friendly Redirect Checker

Here are some ways you can handle the code to pass a 301 redirect in ASP.NET and IIS:

IIS Redirect
In internet services manager, right click on the file or folder you wish to redirect
Select the radio titled "a redirection to a URL".
Enter the redirection page
Check "The exact url entered above" and the "A permanent redirection for this resource"
Click on 'Apply'

Redirect in ASP
   Response.Status="301 Moved Permanently" Response.AddHeader "Location", " http://www.new-url.com"


Redirect in ASP .NET
private sub Page_Load(object sender, System.EventArgs e)

   Response.Status = "301 Moved Permanently"
   Response.AddHeader("Location","
http://www.new-url.com")

end sub

I will make another entry later this week about how to create a handler, most likely one that leverages the code for the URLMapping handler I posted about the other day.

Posted: Tuesday, February 14, 2006 4:50 PM

by Chris Love
Filed under: , ,

Comments

Chris Love's Official Blog - Professional ASP.NET said:

Last week Jonathan Hochman wrote an article about how URL Rewriting does not work properly on the ASP.NET/IIS

# September 24, 2007 8:13 PM

Rick Lim said:

Thanks for this tutorial. I had been wondering how to do that until i read this.
# August 23, 2008 10:31 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS