Url重写

        /// <summary>
        
/// 重写Url
        
/// </summary>
        
/// <param name="sender">事件的源</param>
        
/// <param name="e">包含事件数据的 EventArgs</param>
        private void ReUrl_BeginRequest(object sender, EventArgs e)
        {
            HttpContext context = ((HttpApplication)sender).Context;
  

            
string requestPath = context.Request.Path.ToLower();

            
if (判定)
            {
                   
                    
foreach (SiteUrls.URLRewrite url in SiteUrls.GetSiteUrls().Urls)
                    {
                        
if (Regex.IsMatch(requestPath, url.Pattern, RegexOptions.Compiled|RegexOptions.IgnoreCase))
                        {
                            
string newUrl = Regex.Replace(requestPath.Substring(context.Request.Path.LastIndexOf("/")), url.Pattern, url.QueryString, RegexOptions.Compiled|RegexOptions.IgnoreCase);
                    
                            context.RewritePath(目标
);

                            
return;
                        }
                    }
                    context.RewritePath(目标);
                
                  }

                }
            }


posted @ 2007-08-13 21:16  KidYang  阅读(291)  评论(0编辑  收藏  举报