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

 BeginRequest事件中,未设置Session会话。

如果要判断Session值,需要在AcquireRequestState事件中校验。

相关文章:

  • 2022-02-27
  • 2021-08-16
  • 2021-09-14
  • 2022-02-15
猜你喜欢
  • 2021-11-08
  • 2021-09-30
  • 2021-09-16
  • 2021-06-18
  • 2021-07-09
相关资源
相似解决方案