利用Global 的BeginRequest事件实现域名的重写
时间:2015-09-16 17:27:45
收藏:0
阅读:291
直接可以通过Global.asax文件中的Application_BeginRequest事件就可以实现域名的重写,如果Global.asax中没有Application_BeginRequest方法,可直接添加。
void Application_BeginRequest(object sender, EventArgs e)
{
string path = Request.Url.ToString();//获取地址栏地址
if (Regex.IsMatch(path, "http://www.xiaobaw.com", RegexOptions.Compiled | RegexOptions.None | RegexOptions.IgnoreCase))
{
Context.RewritePath("/web/flack/Index.aspx"); //重写地址
}
else if (Regex.IsMatch(path, "/(.+).xiaobaw.com", RegexOptions.Compiled | RegexOptions.None | RegexOptions.IgnoreCase))
{
Context.RewritePath("/web/cyan/Index_s.aspx");
}
}
原文:http://www.cnblogs.com/wdx-621/p/4813694.html
评论(0)