您的位置:首页 > 编程语言

如何编程方式设置301跳转?

2014-07-17 11:45 211 查看
我们知道IIS的301设置非常的简单,不懂得可以去百度下。

编程方式使用下面的代码

答案:   /// <summary>
/// 设置301跳转
/// </summary>
/// <param name="Url">要跳转的URL</param>
public static void SetURL301(string Url)
{
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.StatusCode = 301;
System.Web.HttpContext.Current.Response.Status = "301 Moved Premanet";
System.Web.HttpContext.Current.Response.AddHeader("Location", Url);
}
//在你的页面pageload事件中编写就可了,如果有其他的需要,自行解决哦
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐