Alex Rivera | Logout

Response.Redirect HTTP status code

Asked 2009-11-12T16:24:54.500
20

Why is it that ASP/ASP.NET Response.Redirect uses a HTTP-302 status code ("Moved Temporarily") even though in most cases a HTTP-301 status code ("Moved Permanently") would be more appropriate?

Edit
Report

2 Answers

19

I've used this handy Permanent Redirect with success:

public void RedirectPermanent(string newPath)
{
  HttpContext.Current.Response.Clear();
  HttpContext.Current.Response.Status = "301 Moved Permanently";
  HttpContext.Current.Response.AddHeader("Location", newPath);
  HttpContext.Current.Response.End();
}
answered 2009-11-12T17:01:23.893
-1

The error you are getting is not due to response.redirect !

The HTTP response status code 301 Moved Permanently is used for permanent redirection, meaning current links or records using the URL that the 301 Moved Permanently response is received for should be updated to the new URL provided in the Location field of the response.

answered 2012-09-07T18:40:56.473

Your Answer