301 永久重定向跳转 global.asax
周祥·
2014-05-08·
1 次阅读
今天做网站升级时 为了给原收录网站转向到原网站 做了一个301 处理 记录一下 在Global.asax文件中的Application_BeginRequest事件中写:
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.StatusCode = 301;
System.Web.HttpContext.Current.Response.Status = "301 Moved Permanently";
System.Web.HttpContext.Current.Response.AddHeader("Location", newurl);判断条件 自行添加