Response.Redirect HTTP status code

前端 未结 5 1601
梦如初夏
梦如初夏 2020-12-06 00:10

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\") wou

5条回答
  •  清歌不尽
    2020-12-06 00:56

    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();
    }
    

提交回复
热议问题