Response.Redirect()
function for a long while now without delving much into it's actual functionality. Recently I've been thinking about the various instances of where I've used the function and how it relates to page progression (particularly in web-based applications) and published HTTP standards.Response.Redirect()
produces a 302 HTTP status. Here's the relevant standard:302 FoundThis defines a 302 status as a temporary redirect. This is appropriate for many of the circumstances where I've used the redirect function. However, reading the range of possible 3xx status codes reveals others that are more appropriate in certain circumstances.
The requested resource resides temporarily under a different URI. Since the redirection might be altered on occasion, the client SHOULD continue to use the Request-URI for future requests. This response is only cacheable if indicated by a Cache-Control or Expires header field.
301 Moved PermanentlyThis defines a 301 status as a permanent redirect, i.e. the page has been moved. This would probably be appropriate for my custom 404 script which redirects for certain URLs. It would probably also be a preferable response for search engine spiders, rather than the current 404.
The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise.
303 See OtherThis defines a 303 status that indicates a response can be found at another page. Basically it tells the browser to fetch the indicated page automatically. The page that generates this status is not placed in the browser's history. I think this would be a better choice for web applications (such as IERI) than the
The response to the request can be found under a different URI and SHOULD be retrieved using a GET method on that resource. This method exists primarily to allow the output of a POST-activated script to redirect the user agent to a selected resource. The new URI is not a substitute reference for the originally requested resource. The 303 response MUST NOT be cached, but the response to the second (redirected) request might be cacheable.
Response.Redirect()
function.This response is new with HTTP 1.1, meaning that HTTP 1.0-compliant browsers will not treat this status in the way defined by the spec. Testing with Netscape Navigator 4.x bears out this fact. Rather than fetch the new page NN4 attempts to load the content. Body content redirecting to the new page is necessary for backwards compatibility.
The ASP to define a 3xx code other than that provided by Response.Reis as follows:
<%@ Language=VBScript %>
<%
Response.Status="3xx STATUS_MSG"
Response.AddHeader "Location", "NEW_LOCATION"
%>
<html>
<head>
<title>Object moved</title>
</head>
<body>
<h1>Object Moved</h1>
<p>This object may be found <a href="NEW_LOCATION">here</a>.</p>
</body>
</html>
Where 3xx
is the status code, STATUS_MSG
is the message, and NEW_LOCATION
is the redirect URL.