Did you find this useful?
Socialize it today.


Redirect Methods Using ASP

Thursday, August 30, 2012

tags ASP

ASP, like many other server-side scripting languages, has the ability to help you implement code that can redirect a user to another web page. The most common technique for redirecting users is using the Reponse.Redirect method. However, you should be aware of the implications of using the Response.Redirect method vs other methods which may be more appropriate for situations that deal with sending users to different pages.


<% Response.Redirect("default.asp") %>

HTTP 302 Status

An ASP page that contains the Response.Redirect method and is executed by the web server will stop processing the rest of the code on the page and returns a "302 Object Moved" back to the client browser within the header. While the result of sending the user to the new page was achieved, it may not be the most optimal method when considering all of your visitors, including web spiders.

For example, if you set up a new domain name and you decided to use the Response.Redirect method on your old pages to redirect your users to the new site, the result of using this technique would work because it will get your visitor to the new location. However, this technique while good for human visitors may work, it is not the best method for informing web spiders that you have moved to a new domain name.


<% Response.Redirect("http://www.new-domain.com") %>

HTTP 301 Status

Rather than using the Response.Redirect method, it would be preferable to send back the appropriate headers, not only to redirect the visitor to the new page, but also inform the user agent that the page has been "Moved Permanently".


<%
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", "http://www.new-domain.com"
%>

The 301 redirect is the most Search Engine (SEO) Friendly method for web page redirection. The main advantage is that using this technique will preserve your search engine rankings for that particular page. Search engines will update their databases accordingly to the new information gathered from the 301 Redirect.

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.



Recommended Books & Training Resources

Beginning ASP Databases Sams Teach Yourself Active Server Pages 3.0 in 21 Days ASP In A Nutshell