1 protected void Application_BeginRequest(object sender, EventArgs e)
2 {
3 string url = Request.RawUrl.ToString();
4 if (url.ToLower().IndexOf("page/bloglist/") > -1 && url.IndexOf("?") < 0)
5 {
6 int lastg = url.LastIndexOf("/");
7 int lastdot = url.LastIndexOf(".aspx");
8 string nurl = String.Format("{0}/blog.aspx?sid={1}", url.Substring(0, lastg), url.Substring(lastg + 1, lastdot - lastg - 1));
9 HttpContext.Current.RewritePath(nurl);
10 }
11
12 }

刚开始这段代码的意思是当请求到类似如:page/bloglist/123456789.aspx 的页面的时候,将其自动转向页面:

blog.aspx?sid=123456789 的页面.当然page/bloglist/123456789.aspx 这个页面 是实际不存在的,这也就是为什么 大家称这种方法是伪静态的原因了.

相关文章:

  • 2021-10-16
  • 2021-12-17
  • 2021-12-21
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2022-01-24
猜你喜欢
  • 2021-09-21
  • 2022-01-09
  • 2021-12-05
  • 2022-12-23
  • 2021-07-17
  • 2021-11-01
相关资源
相似解决方案