首页 > 代码库 > asp.net URL重写

asp.net URL重写

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);        }    }

 

asp.net URL重写