代码改变世界

301 永久重定向

2010-08-14 20:32  音乐让我说  阅读(190)  评论(2编辑  收藏  举报

代码如下:

 

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"); //新地址
            }
        }
    }
}

 

等待更新...