当前位置: 移动技术网 > IT编程>开发语言>.net > ASP.NET MVC3 实现全站重定向的简单方法

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

2017年12月12日  | 移动技术网IT编程  | 我要评论

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", "//www.jb51.net"));
            }
        }

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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网