/// <summary>
///重定向代码
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void Application_BeginRequest(object sender, EventArgs e)
{
Uri url = Request.Url;
string host = url.Host.ToLower();
string strWebURL = "www.yuming.com";//此处是带www.的域名
if (url.AbsoluteUri.IndexOf(strWebURL) == -1)
{
Response.Status = "301 Moved Permanently";
// 避免替换掉后面的参数中的域名
Response.AddHeader("Location", url.AbsoluteUri.Replace(string.Format("http://{0}", host), string.Format("http://www.{0}", host)));
Response.End();
}
}