Response.Redirect and 302 and 301 status codes

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. This is important for search engines and other crawlers that might need to know the definitive url.

To send a 301 redirect:

Response.Status = "301 Moved Permanently";
Response.StatusCode = 301;
Response.AddHeader("Location", url);
Response.End();

Update: ASP.Net 4.0 ads a Response.RedirectPermanent() method.

One thought on “Response.Redirect and 302 and 301 status codes”

  1. What is 301 permanent and 302 temporary http status code redirection and how to implement it in asp.net c#.
    http://www.dotnetbull.com/2013/08/301-permanent-vs-302-temporary-status-code-aspnet-csharp-Implementation.html

Leave a Reply