ASP.NET MVC3 实现全站重定向

MVC3用以下代码实现全站重定向

        protected void Application_BeginRequest(object sender, EventArgs e)
        {
            string strUrl = Request.Url.ToString().Trim().ToLower();
            if (strUrl.Contains("http://xxx.cn"))
            {
                Response.RedirectPermanent(strUrl.Replace("http://xxx.cn", "http://www.xxx.cn")); 
            }
        }

实现如:http://xxx.cn/about 重定向到 http://www.xxx.cn/about

posted @ 2012-07-10 11:36  韩天伟  阅读(1355)  评论(0编辑  收藏  举报