Context.RewritePath 方法重写URL
void Application_BeginRequest(object sender, EventArgs e) { string url = Request.AppRelativeCurrentExecutionFilePath; //~/NewsAdmin/NewsList.aspx?pages=2 //~/NewsAdmin/NewsList_2.aspx Match match = Regex.Match(url, @"(~/NewsAdmin/NewsList)_(\d+)(.aspx)"); if (match.Success) { url = match.Groups[1].Value + match.Groups[3].Value + "?pages=" + match.Groups[2].Value; Context.RewritePath(url); } }
时间: 2024-10-07 09:30:16