Note: http response codes 3xx status codes are indication of Redirection. ** is prefixed for most commonly used status codes.
So let’s start.
**300 Multiple Choices
The HTTP 300 Multiple Choices redirect status response code indicates that the request has more than one possible responses. The user-agent or the user should choose one of them. As there is no standardized way of choosing one of the responses, this response code is very rarely used.
If the server has a preferred choice, it should generate a Location header.
This is typically the case where the URL represents a high level grouping of which lower level selections need to be made e.g. a directory within which the user must select a particular file to access.
**301 Moved Permanently
The requested resource has been assigned a new permanent URI and any future references to this resource should use one of the returned URIs
The new permanent URI should be given by the Location field in the response. Unless the request method was HEAD, the entity of the response should contain a short hypertext note with a hyperlink to the new URI(s).
We should use Response.RedirectPermanent in ASP.Net, which send 301 status code.
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.
The temporary URI should be given by the Location field in the response. Unless the request method was HEAD, the entity of the response should contain a short hypertext note with a hyperlink to the new URI(s).
A 301 redirect means that the page has permanently moved to a new location. A 302 redirect means that the move is only temporary.
If you use Response.Redirect to direct users to a new location, you should be aware that it issues a status code of 302, which means that “the resource resides temporarily under a different URI.” If you intend to communicate that the resource has permanently changed locations, you should not use Response.Redirect. In case of permanent, we should use Response.RedirectPermanent which send 301 status code.
303 See Other
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.
In ASP.Net we can achieve this
HttpContext.Current.Response.Clear(); HttpContext.Current.Response.Status = "303 See Other"; HttpContext.Current.Response.AddHeader("Location", newLocation); HttpContext.Current.Response.End();
**304 Not Modified
If the client has performed a conditional GET request and access is allowed, but the document has not been modified, the server SHOULD respond with this status code. The 304 response MUST NOT contain a message-body, and thus is always terminated by the first empty line after the header fields.
305 Use Proxy
The requested resource MUST be accessed through the proxy given by the Location field. The Location field gives the URI of the proxy. The recipient is expected to repeat this single request via the proxy. 305 responses MUST only be generated by origin servers.
The 306 status code was used in a previous version of the specification, is no longer used, and the code is reserved.
**307 Temporary Redirect
A 307 is the actual Temporary Redirect. It really means temporary, as in the very next request should also be made to the old URL, and the new one should not even be cached. This is usually only used for emergency redirects (like when a primary server is down) and the like.
How it is different than 302?
If the URL is really, really temporary please do use a 307. Only use a 302 if you want the URL that you are redirecting to show up in the search results with the content of the page that you are redirecting to.
So you have page A with a URL and you have page B with content. You want the URL of page A to show up with the content of page B in the index. If that’s what you want, use a 302. If that’s not what you want, use a 307. And if something is not temporary but permanent use a 301 redirect and not anything else.
308 Permanent Redirect (experimental)
The request, and all future requests should be repeated using another URI. 307 and 308 (as proposed) parallel the behaviors of 302 and 301, but do not require the HTTP method to change.
Note: 301 and 302 allow change of request method from POST to GET (i.e. “your submission is received but you should get response elsewhere”); 307 and 308 forbid such behavior.
Below is a flow from which you can get more understanding about status code behavior.
That’s it about Http 3xx status codes. In upcoming articles we’ll discuss about next set of codes.