ASP.NET MVC3 实现全站重定向的简单方法
ASP.NET MVC3 实现全站重定向的简单方法
发布时间:2016-12-29 来源:查字典编辑
摘要:MVC3用以下代码实现全站重定向复制代码代码如下:protectedvoidApplication_BeginRequest(objects...

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

}

}

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

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新asp.net教程学习
热门asp.net教程学习
编程开发子分类