301 永久重定向

代码如下:

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebUI
{
    public partial class TestRedirect : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                //string url = "http://www.baidu.com";
                //Response.Redirect(url,false);
                //string filePath = "http://www.163.com";
                //Response.Write(filePath);

                /* 301 永久重定向 */
                Response.Status = "301 Moved Permanently";
                Response.AddHeader("Location", "http://www.baidu.com"); //新地址
            }
        }
    }
}

 

等待更新...

你可能感兴趣的:(重定向)