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

原文地址:https://www.cnblogs.com/hantianwei/p/2584329.html