您现在的位置是:网站首页> 编程资料编程资料
ASP.NET MVC3 实现全站重定向的简单方法_实用技巧_
2023-05-24
395人已围观
简介 ASP.NET MVC3 实现全站重定向的简单方法_实用技巧_
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
您可能感兴趣的文章:
