MVC3用以下代码实现全站重定向
protected void Application_BeginRequest(object sender, EventArgs e)
{
string strUrl = Request.Url.ToString().Trim().ToLower();
if (strUrl.Contains("http://tuohang.net"))
{
Response.RedirectPermanent(strUrl.Replace("http://tuohang.net", "//www.tuohang.net"));
}
}
实现如:http://tuohang.net/about 重定向到 //www.tuohang.net/about