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(目标);
}
}
}
/// 重写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(目标);
}
}
}
KidYang