There are situations when we need to redirect the visitor to a web site to another place.
This is done for example when the web site is no longer updated or valid.
In order to do so we can redirect the visitor permanently with HTTP 301 response code. That is done because we need to tell the user-agent that the location is permanently moved elsewhere.
I believe you all know what HTTP headers are... or maybe we should start from there...
HTTP headers are components of the message of request and response in an HTTP transaction. Therefore they define the parameters of the transaction.
They normally have the form of pairs and examples are Cache-Control: no-cache or Content-Type:·text/html;·charset=UTF-8. If you need to see headers from a web page, you can always visit Rex Swain's HTTP Viewer submit an URl and get the headers.
In ASP we can redirect to another page using Response.Redirect. However the Response.Redirect will generate a status code of 302 which means "The requested resource resides temporarily under a different URI." (quote from W3C). And that's not ok with us... we need to have a 301 response code.
In the end Response.Redirect is not a feasible solution.
We need to use something else. And the best way is to use a Response.AddHeader. Basically we need to issue the status code and then redirect the user:
We set the status, we add the header and that's it.
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.anothe-site.com/"
I hope the above will help someone. As usual please use the comments section below for sharing your ideas and experiences.