首页 > 编程技术 > ASP.NET

ASP.NET MVC3 实现全站重定向的简单方法

发布时间:2021-9-22 10:12

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

复制代码 代码如下:

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

实现如:http://jb51.net/about 重定向到 https://www.jb51.net/about

标签:[!--infotagslink--]

您可能感兴趣的文章: